How would I go about checking if a collection exists in firestore and then creating it if it doesn't exist? I know how to add a document to the collection if it is created, but how to create an empty collection in Flutter is what I am missing.
1 Answers
5
votes
There is no such thing as an empty collection in Firestore. You can't create a collection without also creating a document it. When you add a document to a collection, it will immediately exist and be visible in the console. When you delete the last document in a collection, it will cease to exist. The only way to check if a document exists is to query it in such a way that it will give you a document.
This is true for all client platforms - there is nothing special here for Flutter.