diff --git a/packages/cloud_firestore/README.md b/packages/cloud_firestore/README.md index 379a5a820924..bfaba2d0fdf9 100755 --- a/packages/cloud_firestore/README.md +++ b/packages/cloud_firestore/README.md @@ -47,15 +47,20 @@ class BookList extends StatelessWidget { return StreamBuilder( stream: Firestore.instance.collection('books').snapshots(), builder: (BuildContext context, AsyncSnapshot snapshot) { - if (!snapshot.hasData) return Text('Loading...'); - return ListView( - children: snapshot.data.documents.map((DocumentSnapshot document) { - return ListTile( - title: Text(document['title']), - subtitle: Text(document['author']), + if (snapshot.hasError) + return new Text('Error: ${snapshot.error}'); + switch (snapshot.connectionState) { + case ConnectionState.waiting: return new Text('Loading...'); + default: + return new ListView( + children: snapshot.data.documents.map((DocumentSnapshot document) { + return new ListTile( + title: new Text(document['title']), + subtitle: new Text(document['author']), + ); + }).toList(), ); - }).toList(), - ); + } }, ); }