Skip to content

Instantly share code, notes, and snippets.

@ijoschek
Last active December 5, 2018 08:58
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/7115e52d60087ec8c25a738ba9a4eaf4 to your computer and use it in GitHub Desktop.
Save ijoschek/7115e52d60087ec8c25a738ba9a4eaf4 to your computer and use it in GitHub Desktop.
flutter_firestore_tut
//...
class _Home extends State<StatefulWidget> {
//...
@override
Widget build(BuildContext context) {
return Scaffold(
//...
Divider(), //Our last line of code
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('docs').snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError)
return Text('Error: ${snapshot.error}');
switch (snapshot.data) {
case null:
return Container();
default:
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
final item = snapshot.data.documents[index];
final itemID =
snapshot.data.documents[index].documentID;
final list = snapshot.data.documents;
//...
},
);
}
},
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment