Load HTML file and display in Flutter Web - flutter-web

I have a single HTML file that contains some JS functions and CSS styling.
Is it possible to load my html file into an embedded widget on Flutter Web? I've successfully accomplished this on iOS and Android using the flutter_webview pacakge, but haven't found a solution for Flutter Web.

There is a HTMLElementView widget which can help you embed Html in flutter web. This widget can take an Iframe and render it. If you don't prefer Iframe then you can embed simply a BodyElement from the dart:html library directly.
An example of embedding Iframe is availabel here. Eventhough its from an old repo, the code is valid and I couldn't find a latest one.
If you don't want do go the tough way, there is simplified widget from Rodydavis which is available here called easy_web_view.
Still if you need code sample a create simple dart pad and share the MRE, I will try to help. :)

For the Iframe example, you can do something like this
First, import 'ui' library, and 'html' library.
import 'dart:ui' as ui;
import 'dart:html';
Second, register your 'Iframe' with viewType 'test-view-type' just for example.
ui.platformViewRegistry.registerViewFactory(
'test-view-type',
(int viewId) => IFrameElement()
..width = '640'
..height = '360'
..src = "https://www.youtube.com/embed/5VbAwhBBHsg"
..style.border = 'none');
Note: you will notice that the compiler can't find platformViewRegistry method but it's okay if you choose to Debug anyway and it will run correctly without any problems.
Finally, use HtmlElementView widget to run this Iframe
return Scaffold(
body: Column(
children: [
Text('Testing Iframe with Flutter'),
HtmlElementView(viewType: 'test-view-type'),
],
));

You can use this package flutter_widget_from_html
While defining the widget you need to set webView: true to get iFrame support
I just tested and it is working fine on web, and this package supports local assets too

Related

Application Layout control and font-awesome

I am using the application layout control from the extension library. In my application banner links I would like to include icons from font-awesome but I do not manage to achieve this.
Someone to the rescue?
Balassaitis says everything I was going say only better and with pictures: https://xcellerant.net/2014/04/07/implementing-font-awesome-4-0-3-in-xpages/
NOTE: the FA classes don't work with the img tag. Use the i tag in your source instead.

Polymer override script loaded by HTML import

Is it possible to access a (Polymer) web component's dependency (also a component) which the only thing it does is load a js script, and override that with another (newer version in my case) script?
Concrete problem: I'm using various Polymer elements (say paper-dialog for example) which use neon-animation whose different animations all import the web-animations HTML which loads the script I want to override.
In other words I would like to perform something like what the /deep/ combinator does for CSS to penetrate into this specific HTML 'component' and add a newer version of the web-animations-next-lite.min.js script.
As for the why: the idea is to use a Chrome extension to perform this since remote update is not an option (internet connectivity limitations). I need to do this since with Chrome v54 our app "broke" (since we use an older web-animations version) by fixing the WebAnimations API so these errors broke animations and with that functionality (popups not appearing).
I already tried injecting the newer version script in my main HTML body with Chrome extension's content script but didn't have any luck there..
Thanks in advance for any ideas!
I know its a bit of a hack, but can't you just put your own version of the web-animations script in bower_components. The problem with trying to alter the polymer element in place is that it will have already loaded the script before you can get at it.
Listen to the load event on you HTML Imports <link>, then add a <script> element with the right src attribute.
It's this last downloaded (and parsed) script that will be taken in account.
<script>
function loaded() {
//file.html loaded
document.write( '<script src="new-file.js"></script>' )
}
</script>
<link rel=import href="file.html" onload="loaded()">

Kentico URL Redirection target options

Is there a way to force a new window for this menu action? I can't see anything. i was thinking of adding a class, and some JS code to redirect if the class is there.
If your only intent is to open a window in a new tab, then why don't you set the target="_blank" in your transformation or where ever you are generating the HTML markup?
I am not saying that it's incorrect, however it's just that you can avoid js for this and rather do it in HTML.
Here's what i've done.
In the Navigation panel, i added the class 'nw'. I have this snippet add the target attribute.
// we need to use .nw as a class to indicate that a link should open in a new window.
$('.nw a, a.nw').each(function(i,v){
var $this = $(this);
$this.attr('target','_blank');
});
You can use the JS option and put in JS like: window.open("http://www.google.com");

Extending SVGGElement using Polymer

I am trying to create a custom element that extends a SVGGlement. Here is the JSBin link to the code: http://jsbin.com/kovumoloda/2/edit?html,console,output
When I run the code, ready() isn't called and so aren't the contents of the Shadow DOM rendered.
I tried the same example without Polymer and it worked. Here is the JS Bin link http://jsbin.com/vihosojofi/1/edit?html,console,output
Is there anything I need to do differently to make this thing work with Polymer ?
Thanks !

How can I display an image as the background of griffon application?

I was trying using the CSSBuilder plugin but it seems that it does not support the CSS background image property.
I have been searching in google and it seems you can add background image to a swing panel by subclassing the panel. But I am pretty new to Swing and I do not know how to do it. I would like to know if there is an easier way to accomplish this with griffon.
Thanks in advanced.
Here's one possible to solution:
install the javatips plugin, i.e, griffon install-plugin javatips
Use the backgroundPanel() node
Here's a barebones example
package sample
import javax.imageio.ImageIO
application(title: 'Sample',
preferredSize: [320, 330],
pack: true) {
backgroundPanel(image: ImageIO.read(app.getResourceAsURL('griffon-icon-256x256.png')))
}

Resources