Instantly share code, notes, and snippets.

@ijoschek ijoschek/.\lib\scr\home.dart Secret
Last active Dec 5, 2018

Embed
What would you like to do?
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