get method

Reads the document referenced by this DocumentReference.

If no document exists, the read will return null.

Implementation

Future<DocumentSnapshot?> get() async {
  debug('REQUEST: GET $documentUri\n');

  http.Response response =
      await httpr.get(Uri.encodeFull(documentUri), headers: headers);

  int httpStatusCode = response.statusCode;

  debug('RESPONSE: $httpStatusCode\n${response.body}');

  if (httpStatusCode == HttpStatus.ok) {
    Map<String, dynamic> jsonResponse =
        json.decode(response.body) as Map<String, dynamic>;
    _id = jsonResponse['id'] as int;
    return DocumentSnapshot._(path, jsonResponse);
  } else {
    return null;
  }
}