listCollections method

Fetches the root collections that are associated with this Firestore database.

Returns a Promise that resolves with an array of CollectionReferences.

firestore.listCollections().then((collections) {
  for (final collection in collections) {
    print('Found collection with id: ${collection.id}');
  }
});

Implementation

Future<List<CollectionReference<DocumentData>>> listCollections() {
  final rootDocument = DocumentReference._(
    firestore: this,
    path: _ResourcePath.empty,
    converter: _jsonConverter,
  );

  return rootDocument.listCollections();
}