列表视图上的 GestureDetector 为列表视图中的所有小部件设置动画,我该如何阻止它。我在 listview 项目上有 Transform.scale ,当我点击小部件时,只有该小部件应该动画,但这里所有其他 listview 项目都在动画。
Widget buildItemCoupens(BuildContext context,int index) {
return Padding(
padding: const EdgeInsets.only(top: 10),
child: Container(
height: 250,
child: Stack(
children: <Widget>[
Positioned(
bottom: -25,
right: 50,
left: 50,
top: 175,
child: GestureDetector(
onTapDown: _onTapDown,
onTapCancel: onTapCancel,
onTapUp: _onTapUp,
onTap: () {
setState(() {
print('$index');
});
},
child:_animatedBtn
),
)
],
),
),
);
}
动画按钮/小部件
Widget get _animatedBtn=>
Transform.scale(
scale: _scale,
child: Container(
//height: 75,
margin: const EdgeInsets.only(
left: 15, right: 15, top: 5, bottom: 45),
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.rectangle,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(15.0),
bottomLeft: const Radius.circular(15.0),
bottomRight: const Radius.circular(15.0),
topRight: const Radius.circular(15.0)),
boxShadow: [
new BoxShadow(
color: Colors.black38,
blurRadius: 15,
),
]),
child: Center(
child: Padding(
padding: const EdgeInsets.all(5),
child: Text(
'JOIN NOW',
style: TextStyle(fontSize: 18, color: Colors.white),
),
)),
),
);