Issue
I have multiple android applications on the market that have the same behavior.
Flutter app not showing the widgets content when run a release app on physical device while the phone locked or the phone screen is off
This also happens when opening the app and closing multiple times sometimes the app goes to a state where only the background is shown without any content, but the widgets are stacked up on each other with no content.
To reproduce you can run a release version of your flutter app on android device: flutter run --release
While your physical phone screen is off. <- this is important.
I didn't get any error or logs to know the source of the issue. I have tried to change the gradle version downgrading to 3.5.0 and upgrading to 7.3.0 but no luck.
I also tried to add WAKE_Lock permission and it didn't work. I tried to create a new project and add my lib file to it and still facing the issue. here is my Yaml File:
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.2
provider: ^6.0.2
http: ^0.13.4
shared_preferences: ^2.0.15
sqflite: ^2.0.2+1
path: ^1.8.0
flutter_svg: ^1.0.0
cached_network_image: ^3.2.1
flutter_vector_icons: ^2.0.0
lottie: ^1.3.0
flutter_staggered_animations: ^1.0.0
flutter_cupertino_datetime_picker: ^3.0.0
path_provider: ^2.0.11
open_file: ^3.2.1
permission_handler: ^10.0.0
url_launcher: ^6.1.3
share_plus: ^4.0.9
flutter_html: ^3.0.0-alpha.1
package_info_plus: ^1.4.2
firebase_core: ^1.18.0
firebase_messaging: ^13.0.0
overlay_support: ^2.0.1
image_picker: ^0.8.5+3
And this is my flutter doctor: Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
[![Run a release app on physical device while its locked][1]][1]
The white strips are a list of card widgets. [1]: https://i.stack.imgur.com/oWp5E.jpg
Solution
I found the issue was in the Global parameters (global provider) that I was using as height and width to define the size of the text and images. when running the app as a release and the phone is closed these parameters didn't get the proper values and they only had the initial values of zero.
Answered By - Mohammed Fadhl
Answer Checked By - Marilyn (JavaFixing Volunteer)