Flutter Webview不适用于Flutter Web

编程入门 行业动态 更新时间:2024-10-26 10:37:17
本文介绍了Flutter Webview不适用于Flutter Web的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试通过URL在webview中显示一个网页. 我已经尝试过flutter_webview_plugin插件,但是当我在浏览器中运行该项目时,该插件无法正常工作.

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.

还有其他方法可以在颤动的Web应用程序中显示网页吗?

Is there any another way to show the webpage in the flutter web application?

推荐答案

flutter_webview_plugin将网页嵌入到应用程序中.在Flutter网站中,您应该使用HtmlElementView小部件. 那里的大多数演示都使用IFrameElement嵌入网页.您可以检查此 easy_web_view 软件包,以自动处理移动平台和Web平台. 根据部署情况,它会在内部自动使用HTMLElementView和WebView.

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.

在此处

更新以添加onLoad侦听器

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'), ), ), );

更多推荐

Flutter Webview不适用于Flutter Web

本文发布于:2023-11-27 05:06:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636718.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不适用于   Flutter   Webview   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!