If your flutter webview (based on webview_flutter) doesn’t load or you constantly see blank white page, Then you need to do the following settings.
- For iOS
In your Info.plist add the below lines
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
With the first key, you can view the page on flutter app, with second and third keys, you are letting insecure url to be loaded.
One of the example is using without https. You must just use http url.
2. For Android
in /android/app/src/main/res/xml/network_security_config.xml file add the below line
<?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>
and in
/android/app/src/main/AndroidManifest.xml file add the below lines with in application tag
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
also allow internet connectivity permission
<uses-permission android:name="android.permission.INTERNET" />
You might have to delete the app and restart. Then it should work better.
3. Another solution
Change the code in the plugin itself. You can find the path for the plugin like below. It’s 0.3.17. For the latest updated version the path should be the same as well. But you if it’s different than you have to find by yourself.
webview_flutter-0.3.17\android\src\main\java\io\flutter\plugins\webviewflutter\FlutterWebView.java
Add the below line:
webView.getSettings().setMixedContentMode(webView.getSettings().MIXED_CONTENT_ALWAYS_ALLOW);
4. Base URL
If you are using android emulator, try to use http instead of https for your base url.