I have a problem when I try to delete the item and it doesn't accept to delete the item. I am using ConfirmDismiss.
Error:
Unhandled Exception: type 'Null' is not a subtype of type 'bool' _DisMissState.build.. (package:advanced_part_2/dismissible.dart:84:30)
_DismissibleState._handleDismissStatusChanged (package:flutter/src/widgets/dismissible.dart:498:11)
Code:
confirmDismiss: (DismissDirection dir) async {
if (dir == DismissDirection.startToEnd) {
// AlertDialog ad =
final bool res = await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Text('Are You Sure you want to delete'),
actions:<Widget> [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(
'cancel',
)),
ElevatedButton(
onPressed: () {
setState(() {
genList.removeAt(index);
});
Navigator.of(context).pop();
},
child: Text(
'Delete',
style: TextStyle(color: Colors.red),
))
],
);
},
);
return res;
} else {
return true;
}
},
