Flutter android grey screen in release mode even if there are no errors or red screens in debug mode

你。 提交于 2021-01-05 09:12:18

问题


I am getting grey screen on startup just after the splash screen on android real device. I have solved all errors or red screens and after that tried again but still it remains the same.

Note: I have released 2 versions of this app before this one to play store. So this is not the first one.

My log

Flutter run key commands.
h Repeat this help message.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter (24661):                              <-- stops here nothing after this

回答1:


Sometime it works well in debug mode but not working in release mode. You may catch that error by running below command in your terminal.

 flutter run --release 

The command compiles to release mode. When grey screen happened, you can check your debug console.




回答2:


Nothing worked for me as there was no error in the UI. The error was at the beginning of the app in the main. After adding await before Firebase.initializeApp(); worked like miracle.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  **await** Firebase.initializeApp(); //adding await solved the problem
  SharedPreferences.getInstance().then((prefs) {
    var brightness = SchedulerBinding.instance.window.platformBrightness;
    if (brightness == Brightness.dark) {
      prefs.setBool('darkMode', true);
    } else {}
    var darkModeOn = prefs.getBool('darkMode') ?? false;
    runApp(
      ChangeNotifierProvider<ThemeNotifier>(
        create: (_) => ThemeNotifier(darkModeOn ? darkTheme : lightTheme),
        child: MaterialApp(
          home: root(),
        ),
      ),
    );
  });
}


来源:https://stackoverflow.com/questions/64962194/flutter-android-grey-screen-in-release-mode-even-if-there-are-no-errors-or-red-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!