Flutter - WebVIew doesn´t work with HTTP

1,069 views
Skip to first unread message

Bruno Zan

unread,
Mar 26, 2020, 3:47:16 PM3/26/20
to Flutter Development (flutter-dev)
Hello, I´m trying to use Webview on my flutter App.

My problem: Webview only works with HTTPS protocol, pages with HTTP doesn´t work.

// "http://www.erechim.rs.gov.br/sys530/publico"
// "https://portal.systempro.com.br:8181/sys152/login.xhtml",

Both applications are build by my company, so we are sure that java and server configurations are the same.

I already tried this setup but didn´t solve the problem:
https://medium.com/flutter-c%C3%B4te-divoire/how-to-set-up-a-basic-flutter-webview-from-a-to-z-8c659b292ec4

and this one too:
http://android--kotlin.blogspot.com/2019/03/android-webview-neterrcleartextnotpermi.html

@override
Widget build(BuildContext context) {
return Scaffold(

body: WebView(
initialUrl: "https://portal.systempro.com.br:8181/sys152/login.xhtml",
// "http://www.erechim.rs.gov.br/sys530/publico"
// "https://portal.systempro.com.br:8181/sys152/login.xhtml",
// "https://www.youtube.com/watch?v=tAGnKpE4NCI",
gestureNavigationEnabled: false,
debuggingEnabled: false,
javascriptMode: JavascriptMode.unrestricted,
),
);
}

AndroidManifest:
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:largeHeap="true"
android:allowBackup="false"
android:supportsRtl="true">

NetworkSecurity.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>

dependencies:
dependencies:
flutter:
sdk: flutter
webview_flutter: ^0.3.19+9

Any tips for this? I´ts common to use http pages, I can´t believe I´m wasting time with this hahaha.

Best Regards from Brazil.
Bruno Zanoelo

Igor Karelin

unread,
Mar 26, 2020, 4:01:50 PM3/26/20
to Flutter Development (flutter-dev), Bruno Zan
Check the logs in your IDE.
For iOS you’ll need to add a key to info.plist to accept http to some domains.


Best regards, Igor Karelin
Flutter Developer on freelance
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/3754a026-2d25-43ac-a253-9cb921a1d4c5%40googlegroups.com.

Bruno Zan

unread,
Mar 30, 2020, 2:45:37 PM3/30/20
to Flutter Development (flutter-dev)
Hello,

I´m actually facing this problem in android, if you could help me do more configurations to make this work in Android I would be glad, because most of my users will use android.

I´m desperate and I´m not finding any solution for this simple situation.
Reply all
Reply to author
Forward
0 new messages