streamWithSearch method
Stream of documents filtered by a single field.
Returns a stream of documents that match the specified field value. The stream updates in real-time when matching documents change.
Usage
StreamBuilder<List<User>>(
stream: userCollection.streamWithSearch(
searchField: 'isActive',
search: true,
),
builder: (context, snapshot) {
// Handle active users
},
);
Performance
- Creates a Firestore query with a where clause
- More efficient than fetching all documents and filtering locally
- Consider adding indexes for frequently searched fields
Implementation
Stream<List<T>> streamWithSearch({required String searchField,required String search}){
return _getCollection.where(searchField,isEqualTo: search).limit(limit).snapshots().map(_snapshots);
}