readDocument method

  1. @override
Future<Map<String, dynamic>?> readDocument(
  1. String collection,
  2. String id
)

Reads a document from the specified collection by ID

Implementation

@override
Future<Map<String, dynamic>?> readDocument(String collection, String id) async {
  final documents = _documents;
  final name = _documentPath(collection, id);

  try {
    final doc = await documents.get(name);
    return _decodeDocument(doc, id: id);
  } on firestore.DetailedApiRequestError catch (error) {
    if (error.status == 404) {
      return null;
    }
    rethrow;
  }
}