I am using AnimatedList in my Flutter app. It is working, but the dismiss-behavior is not smooth because the dismissed item changes to its above item while transitioning.
Here is a Screenvideo for a better understanding. Concentrate on the text, it always changes mid-transition to the text of the first item ("Hallo Das ist 1").
I followed this Tutorial where you can also test it on a CodePad where you can see the exact same behavior. This is not the desired animation... Does anyone know how I can fix this?
Here is how I dismiss the items:
_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);
}
and my slideIt - function for the animation:
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),
),
],
),
);
}
If you need any more info just let know! Any help is appreciated. I hope this can be fixed somehow...