android - Flutter 按住闪屏 3 秒。如何在 Flutter 中实现闪屏?
问题描述
如何在颤动中显示启动屏幕 3 秒,然后进入我的登录屏幕。
我试过.countdowntimer 但导入未解决
import 'package: countDown/countDown.dart';
CountDown cd = new CountDown(new Duration(seconds: 4));
CountDown is unresolved
Android Studio 和颤振
解决方案
我在每个应用程序中使用的简单解决方案。
Timer
在构建方法代码片段中使用类
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
),
);
}
}
推荐阅读
- javascript - 无法通过 AJAX 将数组发送到 php?
- python - 按频率和值对列表进行排序
- indexing - Keras 嵌入位置信息
- rabbitmq - 具有单个连接对象的 RabbitMQ 多个消费者
- sql - SQL Server:来自 JSON 对象数组的连接字符串
- flutter - 为什么 Flutter ListTile onTap 似乎被缓存了?
- sql-server - ASP.NET Core MVC 接受来自用户的列表并更新与该列表匹配的数据库记录
- php - ImageMagick 动画 GIF 压缩
- asp.net - 由于多对多关系MVC,如何设置链接到关联表的多个复选框的值
- android - 想知道我的架构组件是否正确