Flutter app stuck at installing with white screen

Problem Background and Symptoms:

A while ago, I tried setting up the Flutter environment and had a brief experience with it. After a long break, I recently became interested again and wanted to see what changes Flutter has undergone.

  1. I followed the official tutorial to set up the Flutter environment and ran flutter doctor without any issues.
  2. I downloaded a demo app project and tried running it on iOS. After the compilation completed, the app was installed on the simulator, but it got stuck on a white screen.
  3. After killing the app, I manually opened it, and it worked fine.

Attempts and Solutions:

  1. I tried installing it on an Android emulator, but encountered the same issue ❌.
  2. I attempted to run flutter clean to clear the cache, but the problem persisted ❌.
  3. I tried running flutter pub cache clean to clear the dependency cache, but the problem remained ❌.
  4. Running flutter run -v to view the output, I noticed that it got stuck at the line Connecting to service protocol:http://127.0.0.1:57071/0dqLN-ZPpFk=/. I suspected an issue with port 57071, so I ran lsof -i:57071 to check the process ID occupying that port and then killed the process using kill <pid>. However, the issue persisted, and I realized that the service changed ports every time, so the problem wasn’t related to that ❌.
  5. Suddenly, I noticed that every time I ran a Flutter command, the first line was Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!. I remembered that I had changed the source due to a poor network environment in the past. Could it be an issue with this source? I quickly checked the ~/.zshrc file and found the following configuration:
    1
    2
    3
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    export FLUTTER_GIT_URL=https://gitee.com/mirrors/Flutter.g
    I deleted these lines, restarted VSCode, and ran the command again. The problem was resolved. In retrospect, it seems that the content of this source was outdated or incorrect! ✅

In summary, one should not easily trust third-party sources. Configuring the network environment correctly is always the first step in setting up the environment.

After searching on Stack Overflow for a while, I couldn’t find any answers pointing to the source. I’m documenting this experience here, hoping it can help others facing the same issue. ♥️

If the above solution doesn’t resolve your problem, you can refer to:

https://stackoverflow.com/questions/75665760/flutter-run-stuck-on-launching

https://stackoverflow.com/questions/68698437/flutter-app-stuck-at-installing-with-white-screen

Author

calvinche

Posted on

2024-04-13

Licensed under

CC BY-NC-SA 4.0

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×