-
-
Save ijoschek/7a15471a9a29874627741dad72bf6738 to your computer and use it in GitHub Desktop.
flutter_firestore_tut
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
//... | |
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