gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 19:25:12 25 4
gpt4 key购买 nike

我遇到了这个主题的问题,我想在一定时间后更改一个小部件。例如我有这个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com