如何在闪屏中显示闪屏3秒钟,然后进入我的登录屏幕。
我试过了.countdowntimer,但是导入无法解决
import 'package: countDown/countDown.dart'; CountDown cd = new CountDown(new Duration(seconds: 4)); CountDown is unresolved
Android Studio和Flutter
您可以使用延迟执行代码 Future.delayed
Future.delayed
new Future.delayed(const Duration(seconds: 3), () { Navigator.pushNamed(context, '/login'); });
更新
const delay = 3; widget.countdown = delay; StreamSubscription sub; sub = new Stream.periodic(const Duration(seconds: 1), (count) { setState(() => widget.countdown--); if(widget.countdown <= 0) { sub.cancel(); Navigator.pushNamed(context, '/login'); } });