Home > other >  White screen shown when android device is offline with flutter app
White screen shown when android device is offline with flutter app

Time:11-18

When building to a physical Android device with Flutter, the build process will only work if the phone has a connection to the internet. If the phone is in airplane mode the build process will not complete.

I've noticed that after a successful deployment to an Android device that if the device is not connected to the internet, the only thing that is shown is a white screen.

There are no network calls being made prior so I'm trying to ascertain why internet needs to be present for a Flutter app to initially open.

I've searched around but nothing quite covers this anomaly so I'm wondering what others have experienced.

Flutter Doctor results
[✓] Flutter (Channel stable, 3.3.5, on macOS 12.5.1 21G83 darwin-arm, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.73.1)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

CodePudding user response:

The reason for this is that the flutter app - or rather the flutter development tools - are running locally on your development machine.

When using flutter run you will usually notice a message like

Running flutter development tools. Listening on http://localhost:8000

This is what the mobile device connects to in order to load the app. This is also the magic feature that allows you to use hot reload and hot restart during development: It's nothing more than your local webserver refreshing. The app only has to reload that website.


Now when the phone is put in airplane mode, it cannot make a request to your local network and will remain idle in a white screen.

You could circumvent that by installing a release version of the app on your device. The release version will include all the code necessary to run the app locally on the device.

  • Related