即使在调试模式下没有错误或出现红色屏幕,在释放模式下仍会抖动Android灰屏 [英] Flutter android grey screen in release mode even if there are no errors or red screens in debug mode

查看:100
本文介绍了即使在调试模式下没有错误或出现红色屏幕,在释放模式下仍会抖动Android灰屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android real设备上启动屏幕刚出现时,我在启动时出现灰屏.我已经解决了所有错误或红屏,然后再次尝试,但仍然保持不变.

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.

注意:在发布该应用之前,我已经发布了该应用的2个版本.所以这不是第一个.

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

我的日志

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

推荐答案

对我来说没有任何用处,因为UI中没有错误.错误是主要在应用程序的开头.在 Firebase.initializeApp();之前添加 await 后,就像奇迹一样.

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

这篇关于即使在调试模式下没有错误或出现红色屏幕,在释放模式下仍会抖动Android灰屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆