documents property
Future<List<DocumentSnapshot> >
get
documents
Get the documents in this collection.
Implementation
Future<List<DocumentSnapshot>> get documents async {
final restHeaders = headers;
final response =
await httpr.get(Uri.encodeFull(collectionUri), headers: restHeaders);
int httpStatusCode = response.statusCode;
final responseJson = json.decode(response.body) as Map<String, dynamic>;
if (httpStatusCode == HttpStatus.ok) {
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;
}
// All other cases are treated as an error.
throw CarpServiceException(
httpStatus: HTTPStatus(httpStatusCode, response.reasonPhrase),
message: responseJson['message'].toString(),
path: responseJson["path"].toString(),
);
}