futureSubCollection property

Future<Map<String, Stream<List<T>>>> get futureSubCollection

Future that resolves to sub-collections for each document.

Returns a Future that resolves to a map of sub-collection streams. Useful for complex data structures with nested collections.

Usage

final subCollections = await userCollection.futureSubCollection;
for (final entry in subCollections.entries) {
  final postsStream = entry.value;
  // Handle posts stream
}

Requirements

  • subPath must be specified
  • Each document in the main collection must have a sub-collection

Implementation

Future<Map<String,Stream<List<T>>>> get futureSubCollection async {
  assert(subPath != null);
  QuerySnapshot snapshot = await _getCollection.limit(limit).get();
  return _subSnapshot(snapshot);
}