Aka*_*wal 4 flutter flutter-dependencies
我已经在flutter中实现了webView,但是它没有打开我在服务器上做错的php网站。
我是陌生的,尝试使用webview将我的网站网页集成到我的应用程序中,但是没有运气。
Widget build(BuildContext context) {
// TODO: implement build
return WebviewScaffold(
appBar: AppBar(iconTheme:IconThemeData(color: Colors.white),title: Text("Intake Form",style:new TextStyle(color: Colors.white,fontWeight: FontWeight.bold)),backgroundColor:Colors.indigoAccent,automaticallyImplyLeading: false),
url: url,
//url: "http://61.246.39.79:8080/",
withJavascript: true,
supportMultipleWindows: true,
withLocalStorage: true,
allowFileURLs: true,
enableAppScheme: true,
appCacheEnabled: true,
hidden: false,
scrollBar: true,
geolocationEnabled: false,
clearCookies: true,
// usesCleartextTraffic="true"
);
}
Run Code Online (Sandbox Code Playgroud)
我期望输出为正在运行的webview,但会引发错误。
Bok*_*ken 47
在 Flutter 项目的主目录中,您有三个主要文件夹:
- lib = your Dart code
- ios = generated structure for iOS platform
- android = generated structure for Android platform
Run Code Online (Sandbox Code Playgroud)
我们对android目录感兴趣。当您打开它时,您会看到“典型的 Android 应用程序结构”。
所以你必须做两件事:
res进入目录:
my_flutter_project/android/app/src/main/res/
Run Code Online (Sandbox Code Playgroud)
创建xml目录(在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" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)
network_security_config.xml 应该位于路径中:
my_flutter_project/android/app/src/main/res/xml/network_security_config.xml
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到有关此文件的更多信息:
https://developer.android.com/training/articles/security-config
去:
flutter_project/android/app/src/main/AndroidManifest.xml
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml 是 XML 文件,结构为:
<manifest>
<application>
<activity>
...
</activity>
<meta-data >
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
因此,对于<application>PROPERTIES,您必须添加 1 行:
android:networkSecurityConfig="@xml/network_security_config"
Run Code Online (Sandbox Code Playgroud)
application开始标记内):<application
SOMEWHERE HERE IS OK
>
Run Code Online (Sandbox Code Playgroud)
不作为标签:
<application> <--- opening tag
HERE IS WRONG!!!!
<application/> <--- closing tag
Run Code Online (Sandbox Code Playgroud)
Muk*_*ony 28
安卓:
在 flutter_project/android/app/src/main/AndroidManifest.xml 中
添加
<application
....
android:usesCleartextTraffic="true"
....>
Run Code Online (Sandbox Code Playgroud)
苹果系统:
在 flutter_project/ios/Runner/info.plist 中
添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run Code Online (Sandbox Code Playgroud)
运行flutter clean。然后,运行应用程序。
Sil*_*der 18
打开android清单文件(android/app/src/main/AndroidManifest.xml)并添加
android:usesCleartextTraffic="true"到应用程序标签
<application
android:name="io.flutter.app.FlutterApplication"
android:label="tangerine_ui"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
Run Code Online (Sandbox Code Playgroud)
小智 8
在AndroidManifest文件中将usesCleartextTraffic属性设置为true,如下所示。
<application
....
android:usesCleartextTraffic="true"
....>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10252 次 |
| 最近记录: |