Created
August 27, 2021 18:02
-
-
Save mingsai/567d8c7db52830ba6b274c8d064d0964 to your computer and use it in GitHub Desktop.
Dismissable Widget Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return Dismissible( | |
key: Key(index.toString()), | |
onDismissed: (direction) { | |
showDialog( | |
context: context, | |
barrierDismissible: false, | |
builder: (_) => AlertDialog( | |
content: Text( | |
"Do you want to delete task ${currentItem.title}?", | |
), | |
actions: <Widget>[ | |
OutlinedButton( | |
child: Text("No"), | |
onPressed: () { | |
// _rebuildAllChildren(context); | |
Navigator.of(context).pop(); | |
}, | |
), | |
OutlinedButton( | |
child: Text("Yes"), | |
onPressed: () async { | |
await box.deleteAt(index); | |
// _rebuildAllChildren(context); | |
Navigator.of(context).pop(); | |
}, | |
), | |
], | |
), | |
); | |
}, | |
child: CheckboxListTile( | |
title: currentItem.title.isNotEmpty | |
? Text(currentItem.title) | |
: Text('Tap to add a title'), | |
subtitle: currentItem.description.isNotEmpty | |
? Text(currentItem.description) | |
: Text('Tap to add some details'), | |
secondary: Icon( | |
Icons.add_task, | |
), | |
value: currentItem.isMarkedComplete, | |
controlAffinity: ListTileControlAffinity.platform, | |
onChanged: (bool? checked) { | |
if (checked == null) return; | |
setState(() { | |
currentItem.isMarkedComplete = checked; | |
}); | |
}, | |
//CheckboxListTile(value: value, onChanged: (){}) | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment