首页 > 解决方案 > 使用 GestureDetector 的 onLongPressStart 每秒调整图标大小

问题描述

这个问题与Messenger的图标非常相似。只要你按下那个图标,它就会变大。

这会很有趣,其他人很快就会使用!

我是新手,但如果有人对如何实现这一点有想法,我非常愿意提供帮助。

标签: flutterflutter-layoutflutter-animation

解决方案


您可以使用接受动画值的ScaleTransition小部件

_controller = AnimationController(duration: const Duration(milliseconds: 2000), vsync: this, value: 0.1);

_animation = CurvedAnimation(parent: _controller, curve: Curves.bounceInOut);

ScaleTransition(
    scale: _animation,
    alignment: Alignment.center,
    child: child
  )

并在您的 longPress 中调用

_controller.forward();

推荐阅读