我有带有行图标的BottomAppBar。
BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(),
IconButton(),
IconButton(),
],
))
我想制作一个平滑的动画,以便在单击图标时,它会缩小,然后返回其原始大小。我会称其为拍打效果。我知道一种通过一堆animationcontroller来做到这一点的方法,但是有什么方法可以使它变得更容易,例如AnimatedSize还是其他?像这样:0:IconSize = 20.01:onPressed:IconSize = 15.02:IconSize = 20.0
尝试使用AnimatedContainer小部件来做到这一点,并将其包装到GestureDetector中,然后像这样更改容器的宽度和高度:
选择布尔=假;
BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
GestureDetector(child: AnimatedContainer(child: Icon(), width: selected ? 15.0 : 20.0), onTap: () {
setState(() {
selected = !selected;
});
},),
AnimatedContainer(child: Icon(), width: selected ? 15.0 : 20.0),
AnimatedContainer(child: Icon(), width: selected ? 15.0 : 20.0),
],
))