Skip to content

Instantly share code, notes, and snippets.

@ijoschek
Last active December 5, 2018 09: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 ijoschek/7a15471a9a29874627741dad72bf6738 to your computer and use it in GitHub Desktop.
Save ijoschek/7a15471a9a29874627741dad72bf6738 to your computer and use it in GitHub Desktop.
flutter_firestore_tut
//...
class _Home extends State<StatefulWidget> {
//...
@override
Widget build(BuildContext context) {
return Scaffold(
//...
final list = snapshot.data.documents; //Our last line of code
return Dismissible(
key: Key(itemID),
onDismissed: (direction) {
removeFromDb(itemID);
setState(() {
list.removeAt(index);
});
},
// Show a red background as the item is swiped away
background: Container(color: Colors.red),
child: Row(
children: <Widget>[
Expanded(
child: ListTile(
title: Text(item['text']),
),
),
RaisedButton(
color: Colors.blue,
textColor: Colors.white,
splashColor: Colors.blueAccent,
child: const Text('Edit'),
onPressed: () {
clickEdit(item);
},
),
],
),
);
//...
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment