open:animationcontroller

AnimationController

setState(() {}); 이것 안했다가, 삽질 몇시간을 날려버림…

class _AddBookCardState extends State<AddBookCard>
    with TickerProviderStateMixin {
  double bottom = 0;
  AnimationController animationController;
  Animation<double> animation;
  Animation curve;
  bool mounted = true;
 
  @override
  void initState() {
    super.initState();
    print('_AddBookCardState init ${widget.idx}');
 
    animationController =
        AnimationController(duration: const Duration(seconds: 2), vsync: this);
    curve = CurvedAnimation(parent: animationController, curve: Curves.easeOut);
    animation = Tween<double>(begin: 0, end: 200).animate(curve);
 
    animationController.addListener(() {
      setState(() {});
    });
  }
 
  @override
  void dispose() {
    print('_AddBookCardState dispose ${widget.idx}');
 
    animationController?.dispose();
    super.dispose();
 
    mounted = false;
  }


  • open/animationcontroller.txt
  • 마지막으로 수정됨: 2020/12/30 12:18
  • 저자 127.0.0.1