In debug mode my app works but once the apk is built, any place where there is a call to the API(need connection) managed by the flutter_bloc and http, my widgets are no longer displayed (white screens) except AppBars. internet permission added in manifest.
And what’s weird is sometimes the apk works well and other times it doesn’t.
Flutter doctor -v
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [version 10.0.19045.4170], locale fr-TG)• Flutter version 3.19.5 on channel stable at C:srcflutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (2 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain – develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:UserslookAppDataLocalAndroidSdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = C:UserslookAppDataLocalAndroidSdk
• ANDROID_SDK_ROOT = C:UserslookAppDataLocalAndroidSdk
• Java binary at: C:Program FilesAndroidAndroid Studiojbrbinjava
• Java version OpenJDK Runtime Environment (build 17.0.9+0–11185874)
• All Android licenses accepted. [√] Chrome – develop for the web
• Chrome at C:Program FilesGoogleChromeApplicationchrome.exe [√] Visual Studio – develop Windows apps (Visual Studio Build Tools 2019 16.11.26)
• Visual Studio at C:Program Files (x86)Microsoft Visual Studio2019BuildTools
• Visual Studio Build Tools 2019 version 16.11.33529.622
• Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2023.2)
• Android Studio at C:Program FilesAndroidAndroid Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0–11185874) [√] VS Code (version 1.88.0)
• Flutter extension version 3.86.0 [√] Connected device (4 available)
• TECNO BD2 (mobile) • 063211515C009845 • android-arm • Android 10 (API 29)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.19045.4170] • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.106
• Edge (web) • edge • web-javascript • Microsoft Edge 123.0.2420.81 [√] Network resources
• All expected network resources are available.
• No issues found!
2
Answers
When developing Flutter applications, it’s essential to be aware of differences in handling exceptions between debug and profile/release modes.
If you’re encountering gray screens in flutter’s release mode, it’s likely due to unhandled exceptions during widget rendering (mostly related to data handling).
So, I recommend running the app in debug mode and checking console logs and devtools. (You should see an exception that complains).
Here are some of the causes of white screen on release
anchors like width and height
. For example
In that example
GridView
has no anchor points since it is inColumn
, you can give it size by wrapping it in a SizedBox and giving it height and widthExpanded
is usually used wrongly by a lot of flutterdevelopers
For example;
The expanded widget needs to have an anchor point from the direction you are expanding from in its parent, so in this case, you need to give it a parent that will have height and width to act as an anchor point
Flexible(..)
widget which must be handled in a parent with a size
AndroidManifest.xml
file like internet permission, etc, is thesame as of the main
AndroidManifest.xml
file