Search code examples
androidflutterdebuggingerror-handlingrelease

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


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

Solution

  • 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(),
            ),
          ),
        );
      });
    }