android - 如何在一定时间后在 Flutter 中切换 Widgets?

标签 android ios flutter android-animation flutter-animation

我遇到了这个主题的问题,我想在一定时间后更改一个小部件。例如 我有这个 animatedFlutter Screen(屏幕 1),然后在动画结束后我想将屏幕更改为我拥有的任何屏幕,例如。登录();

有什么建议吗?谢谢。

import 'package:flutter/material.dart';
import 'dart:async';

void main() => runApp(AnimatedFlutterLogo());

class AnimatedFlutterLogo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new _AnimatedFlutterLogoState();

}

class _AnimatedFlutterLogoState extends State<AnimatedFlutterLogo> {
  Timer _timer;
  FlutterLogoStyle _logoStyle = FlutterLogoStyle.markOnly;

  _AnimatedFlutterLogoState() {
    _timer = new Timer(const Duration(milliseconds: 800), () {
      setState(() {
        _logoStyle = FlutterLogoStyle.horizontal;
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    _timer.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return new FlutterLogo(
      size: 200.0,
      textColor: Colors.white,
      style: _logoStyle,

    );
  }
}

最佳答案

试试这个,

_Act_NotificationScreenState() {
_timer = new Timer(const Duration(milliseconds: 800), () {
  setState(() {
    _logoStyle = FlutterLogoStyle.horizontal;
  });
  _timer = new Timer(const Duration(seconds: 1), () {
      Navigator.push(context, MaterialPageRoute(builder: (context) => Act_Login()));
  });
});
}

关于android - 如何在一定时间后在 Flutter 中切换 Widgets?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59484959/

相关文章:

flutter - Flutter 中日期选择器的大小

dart - 如何在 Flutter 中围绕图像小部件 float 文本小部件

Flutter:以毫米为单位创建标尺

android - 在项目中添加Monogame的正确方法

Android:如何使用可见性 GONE 对象的空间?

android - Android 中如何减小视频大小?

android - RxJava2,带有用于 Api 调用的改造 2

ios - 在1个非 TableView Controller 中显示多个核心数据实体对象

ios - 'UInt3 2' is not convertible to ' 镜像配置'

iOS Cocoa Touch 添加对象到 NSArray