skip to Main Content

I’m making a whiteboard app using Flutter and Firestore.
This whiteboard app creates a room first, then creates pages, and then draws inside the page.

Firestore has the following configuration:

enter image description here

I need to be able to get the number of subcollections in Firestore to get the number of pages.

How do I get the number of these subcollections(pages)?

2

Answers


  1. There is no function that can return the number of sub-collections that exist within a document. If you need such a count, you need to create this mechanism yourself. But it’s pretty simple, you can create a document in which you can increment/decrement a numeric value, each time a new sub-collection is added or deleted from the document.

    Login or Signup to reply.
  2. You can’t get all collection from one doc in dart.

    Retrieving a list of collections is not possible with the mobile/web client libraries. You should only look up collection names as part of administrative tasks in trusted server environments. If you find that you need this capability in the mobile/web client libraries, consider restructuring your data so that subcollection names are predictable.

    Here is the document link.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search