我非常喜欢扑腾,正在尝试扑扑。我试图实现一个启动画面。 我的要求:
答案 0 :(得分:4)
return new SplashScreen(
seconds: 4,
navigateAfterSeconds: new HomeScreen(),
title: new Text(
'WELCOME TO KIDS MANIA',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
fontFamily: 'Chunkfive'),
),
image: Image.asset("images/splashlogo.png"),
backgroundColor: Colors.lightBlueAccent,
styleTextUnderTheLoader: new TextStyle(fontFamily: 'Chunkfive'),
photoSize: 100.0,
loaderColor: Colors.black,
);
答案 1 :(得分:1)
试试这个
您可以使用Future.delayed()
构造函数
Future.delayed(Duration duration, [ dynamic computation() ])
创建一个在延迟后运行其计算的未来。
计算将在给定的持续时间过去后执行,未来将以计算结果完成,
如果持续时间为0或更短,则在所有微任务运行完毕后,它会在下一个事件循环迭代中完成。
示例代码
new Future.delayed(const Duration(seconds: 3), () {
// You action here
});
答案 2 :(得分:0)
在此处查看完整的代码
import 'package:flutter/material.dart';
import 'package:splashscreen/splashscreen.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return SplashScreen(
seconds: 14,
navigateAfterSeconds: new AfterSplash(),
image: new Image.asset('assets/logo.png'),
backgroundColor: Colors.white,
photoSize: 100.0,
);
}
}
class AfterSplash extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Welcome In SplashScreen Package"),
automaticallyImplyLeading: false),
body: Center(
child: Text(
"Done!",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30.0),
),
),
);
}
}
别忘了添加依赖项
dependencies:
flutter:
sdk: flutter
splashscreen: