fetchAllDocuments method
Fetches all documents from the specified Firestore collection.
This method retrieves all the documents from the specified collection and returns their data as a list of Maps. Each Map corresponds to a document in the collection.
collection
: The name of the Firestore collection.
Returns a Future that resolves to a List of Maps, where each Map represents the data of a document in the collection.
Implementation
@override
Future<List<Map<String, dynamic>>> fetchAllDocuments(
String collection) async {
// Fetch all documents from the specified collection
final snapshot =
await FirebaseFirestore.instance.collection(collection).get();
// Convert the documents to a list of Maps containing their data
return snapshot.docs.map((doc) => doc.data()).toList();
}