Jagadish
Jagadish

Reputation: 1186

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

Upvotes: 2

Views: 2896

Answers (2)

Jagadish
Jagadish

Reputation: 1186

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

Upvotes: 1

John Joe
John Joe

Reputation: 12803

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.

Upvotes: 2

Related Questions