如何在特定点停止动画?

问题描述

我已经创建了此动画来显示配置文件,并且我希望在配置文件图片动画完成后且以下文本的不透明度开始改变之前停止该动画。现在,我知道个人资料图片的动画从0.3变为0.6,因此我想将动画停止在0.6。 这是代码

import 'package:Flutter/cupertino.dart';
import 'package:Flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class profile extends StatefulWidget {
@override
_profileState createState() => _profileState();
}

class _profileState extends State<profile> with SingleTickerProviderStateMixin{

AnimationController _animationController;

Animation<double> barHeight;
Animation<double> avatarSize;
Animation<double> textOpacity;


@override
void initState() {
// Todo: implement initState
super.initState();
_animationController = AnimationController(vsync: this,duration: Duration(seconds: 5));
_animationController.forward();

barHeight = Tween(begin: 0.0,end: 250.0).animate(CurvedAnimation(parent:_animationController,curve: 
Interval(0.1,0.3,curve:Curves.easeInOutQuint)));
avatarSize = Tween(begin: 0.0,end: 1.0).animate(CurvedAnimation(parent:_animationController,curve: 
Interval(0.3,0.6,curve:Curves.easeInOutCirc)));
textOpacity = Tween(begin: 0.0,curve: 
Interval(0.6,1,curve:Curves.easeInOutCirc)));



}


Widget _buildanimation(BuildContext context,Widget child,Size size){
return Container(
  decoration: Boxdecoration(
    image: decorationImage(
      image: Assetimage('assets/bgi1.png'),fit: BoxFit.fill
    )
  ),child: Column(
    children: <Widget>[
      SizedBox(height: 250,child: Stack(
          overflow: Overflow.visible,children: <Widget>[
            Opacity(
              opacity: 0.9,child: Container(
                height: barHeight.value,width: double.infinity,decoration: Boxdecoration(
                image: decorationImage(
                  image: Assetimage('assets/books.jpg'),fit: BoxFit.fitWidth
                )
                ),),Positioned(
              top: 200,left: size.width/2-70,child: Transform(
                alignment: Alignment.center,transform: Matrix4.diagonal3Values(avatarSize.value,avatarSize.value,1.0),child: Container(
                  width: 120,height: 120,decoration: Boxdecoration(
                      borderRadius: BorderRadius.circular(100),child: CircleAvatar(
                    backgroundImage: Assetimage('assets/profile.jpg'),],Padding(
            padding: const EdgeInsets.all(12),child: Column(
              children: <Widget>[
                SizedBox(height: 60,Opacity(opacity:textOpacity.value,child: Text(
                        "Gillian Flynn",style: GoogleFonts.lobster(fontSize: 50,color: Colors.blue[900]),)),SizedBox(height: 40,child: Padding(
                  padding: const EdgeInsets.all(10.0),child: Text(
                      "Gillian Flynn was born in Kansas City,Missouri to two community-college 
professors—her mother taught reading; her father,film. Thus she spent an inordinate amount of her 
youth nosing through books and watching movies. She has happy memories of having A Wrinkle in Time 
pried from her hands at the dinner table,and also of seeing Alien,Psycho and Bonnie and Clyde at a 
questionable age (like,seven). It was a good childhood.",style: GoogleFonts.kanit(fontSize: 15),))
              ],)
        ),);
}

@override
void dispose() {
// Todo: implement dispose
super.dispose();
_animationController.dispose();
}



@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
  body: AnimatedBuilder(
    animation: _animationController,builder: (context,child)=> _buildanimation(context,child,size),)
);
}
}

之所以问这个问题,是因为我想知道是否可以使用一个animationcontroller本身单独执行特定的动画间隔。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...