AnimatedPadding(每日Flutter 小部件)

动画Padding  点击之后 有动画过渡

class AnimatedPaddingWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => AnimatedPaddingWidgetState();
}

class AnimatedPaddingWidgetState extends State<AnimatedPaddingWidget> {
  double AnimatedPaddingOffset = 120;

  @override
  Widget build(BuildContext context) {
    return AnimatedPadding(
        curve: Curves.linear,
        padding: EdgeInsets.all(AnimatedPaddingOffset),
        duration: Duration(seconds: 1),
        child: GestureDetector(
          child: Image.network(
              "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584787666369&di=2595aefbc771e601d57cfc5102135d78&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F68%2F61%2F300000839764127060614318218_950.jpg"),
          onTap: () {
            setState(() {
              AnimatedPaddingOffset = AnimatedPaddingOffset - 10;
            });
          },
        ));
  }
}

  

posted on 2020-03-21 16:17  wjw334  阅读(651)  评论(0编辑  收藏  举报

导航