Skip to content

Instantly share code, notes, and snippets.

@mingsai
Created August 27, 2021 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingsai/567d8c7db52830ba6b274c8d064d0964 to your computer and use it in GitHub Desktop.
Save mingsai/567d8c7db52830ba6b274c8d064d0964 to your computer and use it in GitHub Desktop.
Dismissable Widget Sample
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