Flutter 在AnimatedList中,颤振可忽略使动画两次
我有一个应用程序,在一个动画列表中有两行,每行都有一个不允许通过滑动删除的项目。 我注意到,当您滑动一行以删除它,然后动画运行两次 这是代码:Flutter 在AnimatedList中,颤振可忽略使动画两次,flutter,Flutter,我有一个应用程序,在一个动画列表中有两行,每行都有一个不允许通过滑动删除的项目。 我注意到,当您滑动一行以删除它,然后动画运行两次 这是代码: Widget _buildItem(BuildContext context, int index, Animation<double> animation) { Key k = new Key(_list[index]['item1'].toString()); return Dismissible( key
Widget _buildItem(BuildContext context, int index, Animation<double> animation) {
Key k = new Key(_list[index]['item1'].toString());
return Dismissible(
key: k,
background: Container(color: Colors.red),
child:
buildList(
animation: animation,
selected: _selectedItem == _list[index],
item: _list[index],
),
onDismissed: (direction) {
_remove(index);
},);
}
void _remove(int index) {
_list.removeAt(index);
}
Widget\u buildItem(BuildContext上下文、int索引、动画){
k键=新键(_list[index]['item1'].toString());
可驳回的回报(
关键:k,
背景:容器(颜色:Colors.red),
儿童:
构建列表(
动画:动画,
已选择:_selectedItem==_列表[索引],
项目:_列表[索引],
),
onDismissed:(方向){
_删除(索引);
},);
}
void _remove(整数索引){
_列表。删除(索引);
}
如何解决此问题?您是否介意提供可直接包含在
main.dart
中的可行代码,以便进行测试。