I tried to implement a Streambuilder to my application, but I get an error when I try my code. This is the error I get:
The following NoSuchMethodError was thrown building StreamBuilder(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot>#be008):
The getter 'documents' was called on null.
Receiver: null
Tried calling: documents
And this is the code I tried:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Test'),
),
body: StreamBuilder(
stream: Firestore.instance
.collection('test')
.document('OrRPMJJyPCThMYMi0mUl')
.collection('test')
.snapshots(),
builder: (context, snapshot) {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot reservation = snapshot.data.documents[index];
return ListTile(
title: Text(test['name']),
);
},
);
},
),
);