Below code works fine unless there is an error. Even in case of an error like 'no network' or 'cannot connect to database', the item is dismissed from the list when its shouldn't be deleted. How to handle this in case of errors?
class DismissibleListItem extends StatelessWidget {
const DismissibleListItem({
this.key,
this.product,
this.onTap,
});
final Key key;
final Product product;
final VoidCallback onDismissed;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return Dismissible(
background: Container(color: Colors.red),
key: key,
direction: DismissDirection.endToStart,
onDismissed: (direction) => onDismissed(),
child: ProductListItem(
product: product,
onTap: onTap,
),
);
}
}