• 赚钱入口【需求资源】限时招募流量主、渠道主,站长合作;【合作模式】CPS长期分成,一次推广永久有收益。主动打款,不扣量;

Flutter 组件之 AnimatedModalBarrier

Flutter cps12345 9个月前 (01-22) 284次浏览 0个评论

AnimatedModalBarrier

对ModalBarrier控件的颜色进行动画,用法如下:

class AnimationDemo extends StatefulWidget {
  
  State<StatefulWidget> createState() => _AnimationDemo();
}

class _AnimationDemo extends State<AnimationDemo>
    with SingleTickerProviderStateMixin {
  AnimationController _animationController;
  Animation _animation;

  
  void initState() {
    _animationController =
        AnimationController(duration: Duration(seconds: 2), vsync: this);

    _animation = ColorTween(
            begin: Colors.red,
            end: Colors.blue)
        .animate(_animationController);

    //开始动画
    _animationController.forward();
    super.initState();
  }

  
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        height: 100,
        width: 100,
        child: AnimatedModalBarrier(
          color: _animation,
        ),
      ),
    );
  }

  
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }
}

效果如下:

Flutter 组件之 AnimatedModalBarrier

喜欢 (0)

您必须 登录 才能发表评论!