I am trying to show a webpage in webview via URL.
I have tried flutter_webview_plugin plugin but it was not working when I run the project on the browser.
Is there any another way to show the webpage in the flutter web application?
flutter_webview_plugin is to embed web pages inside an app. In flutter web you should use HtmlElementView widget.
Most demos out there use IFrameElement to embed a webpage. You can check this easy_web_view package for handling both mobile and web platform automatically.
It internally uses HTMLElementView and WebView automatically depending on the case of the deployment.
some example is available here
Update for adding onLoad listener
IFrameElement iframeElement = IFrameElement()
..src = 'url'
..style.border = 'none'
..onLoad.listen((event) {
// perform you logic here.
});
ui.platformViewRegistry.registerViewFactory(
'webpage',
(int viewId) => iframeElement,
);
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: HtmlElementView(viewType: 'webpage'),
),
),
);
if someone facing issue loading mobile side then go with this, its works in Flutter Android, Ios, Web :-
EasyWebView(
height: 400,
width: 1000,
isHtml: false, // Use Html syntax
isMarkdown: false, // Use markdown syntax
convertToWidgets: true,
src: Uri.dataFromString('<html><body><iframe allow="camera *;microphone *" height="100%" width="100%"'
' frameborder="0" src="$url"></iframe></body></html>', mimeType: 'text/html').toString(),
),
you guys can use any webview to load any web page in your web/app in flutter using Url in html just change src = "$url" :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With