FloatingActionButton禁止动画效果

811 阅读1分钟

源码 在这里插入图片描述FloatingActionButton是在Scaffold中的widget,里面还定义了位置和动画

在这里插入图片描述 FloatingActionButtonAnimator如果是null的话 是有默认动画的。

在这里插入图片描述 上图是默认动画。 里面三个方法 getOffset() 、getRotationAnimation()、getScaleAnimation() 重写

class scalingAnimation extends FloatingActionButtonAnimator{
  double _x;
  double _y;
  @override
  Offset getOffset({Offset begin, Offset end, double progress}) {
    _x = begin.dx +(end.dx - begin.dx)*progress ;
    _y = begin.dy +(end.dy - begin.dy)*progress;
    return Offset(_x,_y);
  }

  @override
  Animation<double> getRotationAnimation({Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }

  @override
  Animation<double> getScaleAnimation({Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }
}

结束。不再有动画