3

I am using the webview_flutter plugin to load a page hosted on localhost(server created with dart, on the phone) but I get net::ERR_CLEARTEXT_NOT_PERMITTED and I can't make the server HTTPS.

I've implemented all the solutions here but none of these work:

  • adding a network_security_config.xml file
  • adding the android:usesCleartextTraffic option

Is there any other solution to this?

Ionel Lupu
  • 2,695
  • 6
  • 29
  • 53
  • 1
    hi mate, managed to solve it? Facing same problem here. – Jaime Dec 03 '19 at 02:08
  • I didn't need to use a webserver anymore since webview_flutter can load local files anyways. Idk how I missed that. To load locally store files (html, css and js) you have to provide the full path of the .html file using ` final directory = (await getApplicationDocumentsDirectory()).path; var url = "file:///$directory/path/to/index.html";` and it will load it correctly – Ionel Lupu Dec 03 '19 at 09:46
  • Thing is I need to get the content from a web server. – Jaime Dec 09 '19 at 01:22
  • I reimplemented everything from the top 7 google results about this problem and it worked in the end – Ionel Lupu Dec 09 '19 at 16:18

1 Answers1

0

I'm an android developer,let me tell you.

Open the android manifest file(both debug and release),and add

android:usesCleartextTraffic="true"

to the application tag

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="..."
    android:icon="@mipmap/ic_launcher"
    android:usesCleartextTraffic="true">

release file path android/app/src/main/AndroidManifest.xml debug file path android/app/src/debug/AndroidManifest.xml

enter image description here

enter image description here

duanduan
  • 586
  • 6
  • 3