animationController.forward()中的'from'参数在颤动中到底有什么作用?

问题描述 投票:0回答:1

我很难理解Tween类的begin参数,lowerBound类的AnimationController参数和from函数的forward()参数之间到底有什么区别这在代码段中的animationController对象上调用。哪个参数控制动画的哪个方面?预先感谢。

  Animation animation;
  AnimationController animationController;

  HomeScreenState();


  @override
  void initState() {
    super.initState();
    animationController = AnimationController(vsync: this,duration: Duration(seconds: 1),/*lowerBound,upperBound*/);
    animationController.addListener((){

      if(animationController.isCompleted){
        animationController.reverse();
      } else if(animationController.isDismissed){
        animationController.forward();
      }
      setState(() {

      });
    });
    animationController.forward(/*from:*/);
  }

  @override
  Widget build(BuildContext context) {

    animation = CurvedAnimation(parent: animationController, curve: Curves.easeInOut);
    animation = Tween(begin: -0.5,end: 0.5).animate(animation);
    //other code
flutter flutter-animation
1个回答
0
投票

from的参数AnimationController.forward当您要从当前位置以外的一点播放动画时使用。

© www.soinside.com 2019 - 2024. All rights reserved.