小编Gya*_*nji的帖子

颤动动画如何逐渐淡入/淡出

我开始使用 Flutter 并尝试制作一个在连续淡入淡出的同时旋转的动画。到目前为止旋转有效,但我在褪色效果方面遇到困难。小部件将逐渐变得透明,但在旋转一圈后,它会跳回到不透明状态,然后再次变为透明。我正在尝试解决此问题,但似乎无法找到方法。使用.forward().reverse()不起作用,但我可能错误地实现了不透明动画。

class AnimatedLoader extends AnimatedWidget {
  static final _opacityTween = new Tween<double>(begin: 1.0, end: 0.3);

  AnimatedLoader({
    Key key,
    this.alignment: FractionalOffset.center,
    Animation<double> turns,
    Animation<double> animation,
    this.child,
  }) : super(key: key, listenable: turns);

  Animation<double> get turns => listenable;

  final FractionalOffset alignment;
  final Widget child;

  @override
  Widget build(BuildContext context) {
    final Animation<double> animation = listenable;
    final double turnsValue = turns.value;
    final Matrix4 transform = new Matrix4.rotationZ(turnsValue * math.PI * 2.0);
    return new Transform(
      alignment: alignment,
      transform: transform, …
Run Code Online (Sandbox Code Playgroud)

dart flutter

5
推荐指数
1
解决办法
6371
查看次数

标签 统计

dart ×1

flutter ×1