Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save littleironical/78113322e6b74e38a7fc847a831b04a9 to your computer and use it in GitHub Desktop.
Save littleironical/78113322e6b74e38a7fc847a831b04a9 to your computer and use it in GitHub Desktop.
final CollectionReference items = FirebaseFirestore.instance.collection('Orders');
final body = StreamBuilder<QuerySnapshot>(
stream: items.snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Container(
child: Center(
child: Text('SOME ERROR HAS OCCURED'),
),
);
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Loading();
}
return ListView(
children: snapshot.data.docs.map((DocumentSnapshot document) {
return new ListTile(
title: Text(
document.data()['Name'],
style: TextStyle(color: Colors.white),
),
leading: Text(
document.data()['Price'],
style: TextStyle(color: Colors.white),
),
);
}).toList(),
);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment