fetchDocumentById method

  1. @override
Future<DocumentSnapshot<Object?>> fetchDocumentById(
  1. String collection,
  2. String docId
)
override

Fetches a document from Firestore by its ID.

This method uses FirebaseFirestore's instance to retrieve a document by its ID from the specified Firestore collection.

collection: The name of the Firestore collection. docId: The ID of the document to fetch.

Returns a Future that resolves to a DocumentSnapshot containing the document data.

Implementation

@override
Future<DocumentSnapshot<Object?>> fetchDocumentById(
    String collection, String docId) {
  // Use FirebaseFirestore to fetch the document by its ID from the collection
  return FirebaseFirestore.instance.collection(collection).doc(docId).get();
}