I created a dismissible widget like this:
GestureDetector(
onHorizontalDragUpdate: (DragUpdateDetails event) {
setState(() {
_offsetX = event.globalPosition.dx;
print("Event : ${event.globalPosition.dx}");
});
},
onHorizontalDragStart: (DragStartDetails event) {
setState(() {
_offsetX = event.globalPosition.dx;
print("Event : ${event.globalPosition.dx}");
});
print(_offsetX.abs());
// }
},
child: Dismissible(
key: UniqueKey(),
direction: DismissDirection.endToStart,
onResize: () {},
onUpdate: (details) {
// });
},
onDismissed: (direction) {},
secondaryBackground: AnimatedContainer(
duration: const Duration(milliseconds: 300),
transform: Matrix4.translationValues(_offsetX - 36, 0.0, 0.0),
color: Colors.red,
padding: const EdgeInsets.only(left: 20),
child: const Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons.delete,
color: Colors.white,
size: 36,
),
// Add other widgets here that you want to move with the swipe
],
)),
background: Container(
color: DsColors.secondary,
),
confirmDismiss: (direction) async {
final result = await Future.delayed(const Duration(seconds: 6), () {
return false;
});
return result;
},
child: widget.child,
),
)
I want to when the child is swapped, delete the icon inside secondaryBackground to move from right to left like a swapped child, but when I swap the child onHorizontalDragUpdate won’t be triggered?