本文介绍了颤振保持闪屏3秒钟.如何在Flutter中实现启动画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在闪屏中显示闪屏3秒钟,然后进入我的登录屏幕.

How to show splash screen in flutter for 3 seconds and then go next my login screen.

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

I have tried.countdowntimer but import is unresolved

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

Android Studio&颤抖

Android Studio & Flutter

推荐答案

您可以使用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');
  }
});

这篇关于颤振保持闪屏3秒钟.如何在Flutter中实现启动画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:14