【问题标题】:What exactly does the 'from' parameter in animationController.forward() do in flutter?animationController.forward() 中的 'from' 参数究竟在颤动中做了什么?
【发布时间】:2019-12-23 14:57:02
【问题描述】:

我很难理解 Tween 类的 begin 参数、AnimationController 类的 lowerBound 参数和 forward()from 参数之间到底有什么区别在代码 sn-p 中的 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】:

    AnimationController.forward 的参数from 用于从当前位置以外的点播放动画。

    您可以将其与 youtube 视频的 ?t=timestamp 参数进行比较,该参数允许在非常特定的时间开始播放视频。

    不要与Tween.begin混淆,这对应于动画在动画最开始时应该是什么样子

    【讨论】:

    • “除了一开始”——不应该是“从当前位置开始”吗?
    • @pskink 是的,我的错。固定
    猜你喜欢
    • 2021-04-26
    • 1970-01-01
    • 2011-06-18
    • 2020-05-29
    • 2016-04-15
    • 2022-01-19
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多