使用插件flutter_webview_plugin
ios在ios/Runner/Info.plist
中添加如下代码
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
安卓插件说明文档上没说,但直接运行可能会报的ERR_CLEARTEXT_NOT_PERMITTED
异常。
在android/app/src/main/res/xml
文件架下新建文件network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
修改android/app/src/main/AndroidManifest.xml
文件
<application
.........
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config">
使用
WebviewScaffold(
url: url,
ignoreSSLErrors: true,
withJavascript: true,
appBar: new AppBar(
centerTitle: true,
elevation: 0,
title: Text("网页"),
),
)
网友评论