streams property
Stream of all documents in the collection with real-time updates.
Returns a stream that emits a list of all documents whenever any document in the collection changes. Documents are automatically deserialized to type T.
Usage
StreamBuilder<List<User>>(
stream: userCollection.streams,
builder: (context, snapshot) {
if (snapshot.hasData) {
final users = snapshot.data!;
return ListView.builder(
itemCount: users.length,
itemBuilder: (context, index) => Text(users[index].name),
);
}
return CircularProgressIndicator();
},
);
Performance Considerations
- Emits the entire collection on any change
- Use
limitparameter to control data size - Consider using
futuresfor one-time data fetching
Implementation
Stream<List<T>> get streams{
return _getCollection.limit(limit).snapshots().map(_snapshots);
}