How can I create a new collection in my Firebase Cloud Firestore with a function in my service file with dart and flutter? I searched for that but I can just find how to add data to an existing collection in firebase. Can someone help me? Pls :)
How can I create a new collection in my Firebase Cloud Firestore with a function in my service file with dart and flutter? I searched for that but I can just find how to add data to an existing collection in firebase. Can someone help me? Pls :)
From the Cloud Firestore documentation (here):
Cloud Firestore stores data in Documents, which are stored in Collections. Cloud Firestore creates collections and documents implicitly the first time you add data to the document. You do not need to explicitly create collections or documents.
So what you need to do is to add to a collection as below and your collection will be created:
Firestore.instance.collection("you_Collection_Path").add({
"key":value //your data which will be added to the collection and collection will be created after this
}).then((_){
print("collection created");
}).catchError((_){
print("an error occured");
});