我AnimatedList
在我的 Flutter 应用程序中使用。它正在工作,但dismiss
-behavior 并不顺利,因为在转换时被解雇的项目会更改为上面的项目。
这是一个屏幕视频,以便更好地理解。专注于文本,它总是在过渡到第一个项目的文本(“Hallo Dasist 1”)的中间变化。
我按照本教程进行操作,您也可以在 CodePad 上对其进行测试,您可以看到完全相同的行为。这不是想要的动画......有谁知道我该如何解决这个问题?
以下是我解雇这些项目的方式:
_removeMemoryAtIndex(int index, Month currentMonth) {
listKey.currentState!.removeItem(
index,
(_, animation) => slideIt(
context,
currentMonth,
0,
CurvedAnimation(
parent: animation,
curve: Curves.easeIn,
reverseCurve: Curves.easeOut),
),
duration: Duration(
milliseconds: 500,
),
);
Provider.of<MemoryImageProvider>(context, listen: false)
.removeMemoryAt(index: index);
}
和我的slideIt
- 动画功能:
Widget slideIt(
BuildContext context,
Month currentMonth,
int index,
animation,
) {
Memory memory = currentMonth.memories[index];
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1, 0),
end: Offset(0, 0),
).animate(
CurvedAnimation(
parent: animation,
curve: Curves.easeIn,
reverseCurve: Curves.easeOut,
),
),
child: Column(
children: [
MemoryTile(
memory: memory,
monthName: currentMonth.name,
onTapped: () {
_removeMemoryAtIndex(index, currentMonth);
print('tap on ${memory.description}');
},
),
SizedBox(
height: scaleWidth(20),
),
],
),
);
}
如果您需要更多信息,请告诉我们!任何帮助表示赞赏。我希望这可以以某种方式解决...