documents property

Future<List<DocumentSnapshot>> get documents

Get the documents in this collection.

Implementation

Future<List<DocumentSnapshot>> get documents async {
  final response = await service._get(collectionUri);

  // we expect a collection map with a list of documents in the response
  Map<String, dynamic> responseJson =
      service._handleResponse(response) as Map<String, dynamic>;
  List<dynamic> documentsJson = responseJson['documents'] as List<dynamic>;

  List<DocumentSnapshot> documents = [];
  for (var documentJson in documentsJson) {
    if (documentJson is Map<String, dynamic>) {
      final key = documentJson['name'].toString();
      documents.add(DocumentSnapshot._('$path/$key', documentJson));
    }
  }
  return documents;
}