android - Flutter 按住闪屏 3 秒。如何在 Flutter 中实现闪屏?

如何在 flutter 中显示启动屏幕 3 秒,然后转到下一个我的登录屏幕。

我已经尝试过.countdowntimer 但导入未解决

import 'package: countDown/countDown.dart';
CountDown cd  =  new CountDown(new Duration(seconds: 4));
CountDown is unresolved 

Android Studio 和 Flutter

最佳答案

Simple solution which i use in every app.

在构建方法中使用 Timer 类 代码 fragment

class SplashScreen extends StatefulWidget {
  @override
  Splash createState() => Splash();
}

class Splash extends State<SplashScreen>  {

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

  }
  @override
  Widget build(BuildContext context) {
        Timer(
            Duration(seconds: 3),
                () =>
            Navigator.of(context).pushReplacement(MaterialPageRoute(
                builder: (BuildContext context) => LandingScreen())));


    var assetsImage = new AssetImage(
        'images/new_logo.png'); //<- Creates an object that fetches an image.
    var image = new Image(
        image: assetsImage,
        height:300); //<- Creates a widget that displays an image.

    return MaterialApp(
      home: Scaffold(
        /* appBar: AppBar(
          title: Text("MyApp"),
          backgroundColor:
              Colors.blue, //<- background color to combine with the picture :-)
        ),*/
        body: Container(
          decoration: new BoxDecoration(color: Colors.white),
          child: new Center(
            child: image,
          ),
        ), //<- place where the image appears
      ),
    );
  }
}

https://stackoverflow.com/questions/50129761/

相关文章:

flutter - "Could not connect to lockdownd"尝试运行 flu

flutter - 如何解决家庭酿造的 flutter 医生问题?

asynchronous - Flutter Redux snackbar

dart - Dart AOT 是如何工作的?

dart - 如何在 Flutter 的 ScrollView 中限制滚动距离?

dart - Flutter Dismissible 坚持必须从树中删除列表项

dart - 如何将数据发布到 dart 中的 https 服务器?

dart - 按下时更改 float 按钮图标的方法

dart - 使用 WidgetsApp 的应用导航示例

android - 是否可以同时在 iOS 和 Android 模拟器上启用热重载?