Solving the new HTTPS requirements in Flutter

The new beta includes some unexpected surprises

Lew C
Flutter Community

--

Photo by Florian Berger on Unsplash

Since this morning, after updating my Flutter beta install, it has been refusing to load any resources from HTTP with this error:

Unhandled error Bad
state: Insecure HTTP is not allowed by platform

If you’re here because you’ve been furiously Googling a fix, and you don’t care why it’s broken, and you just want it fixed, here’s what you can do:

  1. Navigate to your project
  2. Go to yourapp\android\app\src\debug\AndroidManifest.xml
  3. Add this line
<application android:usesCleartextTraffic="true">

</application>

4. Build your debug app and deploy it to your device of choice. It should work now.

Why is this happening?

Since a change in dart_sdk last month, outbound connections are checked to see if they are permitted to occur in plaintext HTTP. The commit that includes this change can be seen here. To be precise, this is the particular lines that are causing us grief:

--

--