gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 12:40:04 25 4
gpt4 key购买 nike

如何在 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
),
);
}
}

关于android - Flutter 按住闪屏 3 秒。如何在 Flutter 中实现闪屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50129761/

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