如何实现Flutter WebView缩放以适合

时间:2019-06-28 07:56:38

标签: flutter dart

我想在颤抖的webview中实现类似的目的。 enter image description here

但是得到这样的东西。 enter image description here

我该如何实现第一种图像的Webview来缩小页面。

3 个答案:

答案 0 :(得分:1)

您必须将useWidePortView设置为true。

Widget build(BuildContext context) {
   return WebviewScaffold(
   initialChild: Loading(),
   appBar: AppBar(
     title: Text(title),
   ),
   url: url,
   withZoom: true,
   scrollBar: true,
   withJavascript: true,
   useWideViewPort: true,
 );
}

答案 1 :(得分:0)

您的第二张图片是Webview真实图片的缩放。要缩放网页视图页面,您可以编写以下代码。

routes: {
"/webview": (_) => WebviewScaffold(
url: url,
appBar: AppBar(
title: Text("Webview"),
),
withJavascript: true,
withLocalStorage: true,
withZoom: true,
)
}

答案 2 :(得分:0)

我知道得晚了,但也许对其他人有用。我可以通过如下设置withWideViewPort和withOverviewMode为真

来实现它
WebviewScaffold(
userAgent: 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94Mobile Safari/537.36',
      withJavascript: true,
      clearCache: true,
      clearCookies: true,
      withZoom: true,
      scrollBar: true,
      useWideViewPort: true,
      url: widget.data.url,
      withOverviewMode: true,`
)