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