diff --git a/lib/check_list.dart b/lib/check_list.dart index 2f1d250..2f28ecc 100644 --- a/lib/check_list.dart +++ b/lib/check_list.dart @@ -95,39 +95,38 @@ class _CheckList extends State { return Dismissible( key: Key(list[index].id.toString()), confirmDismiss: (direction) async { - if (direction == DismissDirection.startToEnd) { + var item = list[index]; + if (direction == DismissDirection.endToStart) { setState(() { - _removeItem(list[index]); + _removeItem(item); list.removeAt(index); }); return true; } + _updateItem(item); setState(() { - list[index].value = !list[index].value; + item.value = !item.value; }); return false; }, - secondaryBackground: Container( - child: Container( - color: Colors.blue, - child: Row(children: const [ - Spacer(), - Padding( - padding: EdgeInsets.all(10), - child: Icon(Icons.check)), - ])), - ), background: Container( - child: Container( - color: Colors.red, - child: Row(children: const [ - Padding( - padding: EdgeInsets.all(10), - child: Icon( - Icons.delete_forever, - )), - Spacer(), - ])), + color: Colors.blue, + child: Row(children: const [ + Padding( + padding: EdgeInsets.all(10), + child: Icon(Icons.check), + ), + Spacer(), + ]), + ), + secondaryBackground: Container( + color: Colors.red, + child: Row(children: const [ + Spacer(), + Padding( + padding: EdgeInsets.all(10), + child: Icon(Icons.delete_forever)), + ]), ), child: CheckboxListTile( title: TextFormField(