gpt4 book ai didi

android - 在 flutter 应用程序中添加启动画面的正确方法是什么?

转载 作者:IT王子 更新时间:2023-10-29 07:09:57 24 4
gpt4 key购买 nike

我正在开发一个基于 flutter 的应用程序,并研究了有几种添加启动画面的方法。但我不确定哪一个是最好的。

最佳答案

    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:mingup/screen/login_screen.dart';

// This is the Splash Screen
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin{

AnimationController _animationController;
Animation<double> _animation;

@override
void initState() {
// TODO: implement initState
super.initState();
_animationController = new AnimationController(
vsync: this,
duration: new Duration(milliseconds: 500)
);
_animation = new CurvedAnimation(
parent: _animationController,
curve: Curves.easeOut,
);

_animation.addListener(()=> this.setState((){}));
_animationController.forward();

Timer(Duration(seconds: 10), (){
Navigator.push(context, MaterialPageRoute(builder: (context) => LoginScreen()));
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
child: Image.asset(
'images/splashscreenbg.png',
fit: BoxFit.cover,
)
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 2,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlutterLogo(
size: _animation.value * 100.0,
),
Padding(padding: EdgeInsets.only(top: 10.0)),
Text("MingUp", style: TextStyle(color: Colors.white, fontSize: 24.0, fontWeight: FontWeight.bold),)
],
),
),
),
]
)
],
),
);
}
}

关于android - 在 flutter 应用程序中添加启动画面的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52360610/

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