我尝试使用Animation.curve制作徽标动画,但当我使用Curves.elasticInOut时,我收到错误消息“BoxConstraints具有负的最小高度"。...请帮助
class InitState extends State<SplashScreen> with SingleTickerProviderStateMixin {
后期动画控制器控制器;后期动画_动画;
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: const Duration(seconds: 5));
_animation = CurvedAnimation(parent: _controller, curve: Curves.elasticInOut);
_controller.forward();
_animation.addStatusListener((status) {
if (status == AnimationStatus.completed) {
startTimer();
}
});
_controller.addListener(() {
setState(() {});
});
Widget initWidget() {
return Scaffold(
body: Stack(
children: [
Container(
decoration: const BoxDecoration(
color: Color(0xff0d0d0d),
gradient: LinearGradient(
colors: [
(Color(0xff3F3F3F)),
(Color(0xff2D2D2D)),
],
begin: Alignment.topCenter,
end: Alignment.topCenter,
),
),
),
Center(
child: SizedBox(
height: _animation.value * 100,
child: Image.asset('assets/images/foodie_logo.png'),//This is where I get the error
),
)
1条答案
按热度按时间u91tlkcl1#
如果您检查
Curves.elasticInOut
动画的documentation,您可以看到该值可以是负数:用另一个非负值的动画更改动画:
https://api.flutter.dev/flutter/animation/Curves-class.html