删除默认启动画面 android & ios flutter

Mik*_*fik 4 flutter

我更喜欢使用允许我构建整个页面的自定义启动画面。所以,我正在尝试从 android 和 ios 中删除默认启动

void main() async {
  flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  runApp(MaterialApp(
    title: 'Navigation Basics',
    debugShowCheckedModeBanner: false,
    home: new SplashPage(),
    routes: {
      // When navigating to the "/" route, build the FirstScreen widget.
      '/home': (BuildContext context) => new FirstRoute(),
    },
  ));
}

class SplashPage extends StatefulWidget {
  @override
  SplashPageState createState() => SplashPageState();
}

class SplashPageState extends State<SplashPage> {

  void navigationToNextPage() {
    Navigator.pushNamed(context, '/home');
  }

  startSplashScreenTimer() async {
    var _duration = new Duration(seconds: 5);
    return new Timer(_duration, navigationToNextPage);
  }

  @override
  void initState() {
    super.initState();
    startSplashScreenTimer();
  }

  @override
  Widget build(BuildContext context) {

    SystemChrome.setEnabledSystemUIOverlays([]);

    return Container(
        child: new Image.asset('images/banner.png', fit: BoxFit.fill));
  }
}
Run Code Online (Sandbox Code Playgroud)

所以我需要使用颤振从两者中删除默认启动画面

Abi*_*n47 9

默认启动画面不能单独用 Dart/Flutter 覆盖。它们是在 Flutter 运行时初始化时由原生 Android/iOS 上下文显示的控件。因此,您在 Flutter 中创建的任何闪屏小部件都会显示默认启动画面之后。(即使你完全删除了默认的初始图像,在 Flutter 完成加载之前,应用程序也只会是一个空白的屏幕,这是糟糕的设计。)

此处提供了有关如何更改默认初始屏幕的说明。如果您精通原生 Android 或 iOS 开发,那么如果您愿意,您可以更进一步,而不仅仅是简单的图像。