LoginSignup
3

More than 5 years have passed since last update.

[Flutter] animationを使って試してみた。その2

Posted at

おはようございます
どんどん寒くなり、今年もまもなく終わりになります。
頑張りましょう。

以前の投稿(連関)

  1. [Flutter] animationを使って試してみた。

Stateful

Stateful でつかいます。

Curved Animation

  1. [Flutter] アニメーションのCurves
  2. https://docs.flutter.io/flutter/animation/Curves-class.html
 animation = CurvedAnimation(parent: animationController, curve: Curves.bounceOut);

   animation.addStatusListener((status) {
      if (status == AnimationStatus.completed) {
        animationController.reverse();
      } else if (status == AnimationStatus.dismissed) {
        animationController.forward();
      }
    });


class AnimatedLogo extends AnimatedWidget {
  final Tween<double> _sizeAnim = Tween<double>(begin: 0.0, end: 500.0);

//  final CurvedAnimation _sizeAnim = CurvedAnimation(begin: 0.0, end: 500.0);

  AnimatedLogo({Key key, Animation animation})
      : super(key: key, listenable: animation);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    final Animation<double> animation = listenable;
    return Transform.scale(
      scale: animation.value * 50,
      child: FlutterLogo(),
    );
  }
}

ここ注目ポイント。


  return Transform.scale(
      scale: animation.value * 50,
      child: FlutterLogo(),
    );

最後に是非忘れないで~

@override
  void dispose() {
    // TODO: implement dispose
    animationController.dispose();
    super.dispose();
  }

これなら。

  1. 心臓が動いているアニメーションができる。

녹화_2018_11_30_07_32_49_871.gif

参考

  1. https://flutter.io/docs/development/ui/animations/tutorial

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3