utilisez soit la librairie webview_flutter ou webview_flutter_plus
Exemples :
https://blog.codemagic.io/inappwebview-the-real-power-of-webviews-in-flutter/
Afin d’éviter l’erreur : ERR_CLEARTEXT_NOT_PERMITTED
Réference : https://stackoverflow.com/questions/55592392/how-to-fix-neterr-cleartext-not-permitted-in-flutter
Go to directory : my_flutter_project/android/app/src/main/res/
Create xml
directory (in res
!)
And inside xml
add new file with name: network_security_config.xml
and content:
<?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>
network_security_config.xml
should be located in path: my_flutter_project/android/app/src/main/res/xml/network_security_config.xml
Go to:
flutter_project/android/app/src/main/AndroidManifest.xml
In main directory of your Flutter project you have three main folders:
- lib = your Dart code
- ios = generated structure for iOS platform
- android = generated structure for Android platform
We are interested in android directory. When you open it, you will see "typical Android app structure".
So you have to do 2 things:
1) Add new file in res
Go to directory:
my_flutter_project/android/app/src/main/res/
Create xml directory (in res!)
And inside xml add new file with name: network_security_config.xml and content:
<?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>
network_security_config.xml should be located in path: my_flutter_project/android/app/src/main/res/xml/network_security_config.xml
2) Modify AndroidManifest.xml
Go to: flutter_project/android/app/src/main/AndroidManifest.xml
AndroidManifest.xml is XML file, with structure:
<manifest>
<application>
<activity>
...
</activity>
<meta-data >
</application>
</manifest>
So for <application> PROPERTIES you have to add 1 line:
android:networkSecurityConfig="@xml/network_security_config"
Références :