stream property

Stream<T> get stream

Stream of a single document with real-time updates.

Returns a stream that emits the document whenever it changes in Firestore. The document is automatically deserialized to type T.

Usage

StreamBuilder<User>(
  stream: userCollection.stream,
  builder: (context, snapshot) {
    if (snapshot.hasData) {
      final user = snapshot.data!;
      return Text(user.name);
    }
    return CircularProgressIndicator();
  },
);

When to Use

  • Real-time updates for a specific document
  • Live data that changes frequently
  • UI that needs to reflect changes immediately

Implementation

Stream<T> get stream {
  return _getCollection.doc(uid).snapshots().map(_snapshot);
}