get method

Reads the document from the backend.

Implementation

Future<DocumentSnapshot<T>> get() async {
  final List<MaybeDocument> result = await firestore.run(
    (Datastore datastore) =>
        datastore.transactionClient.lookup(<DocumentKey>[key]),
  );
  hardAssert(
    result.length == 1,
    'Expected a single document result, got ${result.length}.',
  );
  final MaybeDocument document = result.first;
  return DocumentSnapshot<T>(
    firestore,
    key,
    document is Document ? document : null,
    converter,
  );
}