future property

Future<T> get future

Future that resolves to a single document.

Returns a Future that resolves to the document once, without real-time updates. Useful for one-time data fetching or when real-time updates are not needed.

Usage

final user = await userCollection.future;
print('User name: ${user.name}');

When to Use

  • One-time data fetching
  • Initial data loading
  • Operations that don't need real-time updates
  • Better performance than streams for single reads

Implementation

Future<T> get future async {
  DocumentSnapshot snapshot = await _getCollection.doc(uid).get();
  return _snapshot(snapshot);
}