I'm using this as an example
https://medium.com/@segaud.kevin/facebook-oauth-login-flow-with-flutter-9adb717c9f2e
to create a http server to serve html to a webview (as a way to serve a local html file and a local javascript file that it references). It returns net::ERR_CLEARTEXT_NOT_PERMITTED when it loads the webview
void main() async {
HttpServer server = await HttpServer.bind("localhost", 8080);
server.listen((HttpRequest request) async {
request.response
..statusCode = 200
..headers.set("Content-Type", ContentType.html.mimeType)
..write("<html><h1>Hello</h1></html>");
});
...
class DemoFlutterWebView3 extends StatefulWidget {
_DemoFlutterWebViewState3 createState() => _DemoFlutterWebViewState3();
}
class _DemoFlutterWebViewState3 extends State<DemoFlutterWebView3> {
Widget build(BuildContext context) {
return WebView(
javascriptMode: JavascriptMode.unrestricted,
initialUrl: "http://localhost:8080/");
}
}
I noticed WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS and added the android:usesCleartextTraffic="true" to the manifest file (guessing here!) but it didn't do anything.
Any ideas why the error or another way to show a html file that references a javascript file?