FlutterFlow Docs
Search…
Creating Collections
A Collection is a group of documents. For example, you could have a users collection that contains a list of documents, each representing a user.
Before you start working with data for your app, you must create a collection in your Firebase Database.

Prerequisites

Before getting started with this section, ensure that you:

Creating Collection

A collection will only show up on Firestore if it contains at least one document.
Here are the steps to create a collection:
  • Click on the Firestore from the Navigation Menu (left side of your screen).
  • Click on the (+) Plus sign button. (right side of Collection label)
  • A popup will appear, Enter the collection name and click Create Button.
  • Define the document scheme using the instructions here.
  • (Optional) Add some data using the instruction here.
For our example, create a collection called todos.

Data Types Within FlutterFlow

The following data types are available within FlutterFlow:
  • Integer: To store numbers such as 100, 4302, 50000, etc.
  • Double: To store a decimal number such as 12.43, 3233.50, 65.5666, etc.
  • String: To store plain text such as title, description, etc.
  • Image Path: To store the URL of the uploaded image.
  • Video Path: To store the URL of the uploaded video.
  • Audio Path: To store the URL of the uploaded audio.
  • Boolean: To store either a true or false value.
  • Record Reference: To store a reference of a document. Storing a reference helps you fetch the document data.
  • Timestamp: To store date and time value.
  • Lat Lng: To store the latitude and longitude of a particular place. Storing Lat Lng value helps you locate a place in Google Maps.
You can find a full list of FireStore data types here. Please note: map fields are not supported at this time.

Creating Fields

A document represents a single item or entity such as user, post, animal, etc. To add data inside the document, you must define the document schema by creating Fields. Creating Fields helps you know what kind of data a document can contain.
Although you can add more fields later on, it's always a good idea to add fields in the first place.
Field Names can not be changed, so it's always good to double-check that you have used the correct Field Names.
Here's how a document schema looks like:
To create Fields for the document:
  • Click on the Firestore in the left side menu.
  • Select your newly created collection from the list on the left side.
  • Click on the + Add Field.
  • Inside the field_name box, enter the name of the field. For example title, description, date, etc.
  • Click on the Data Type dropdown menu and select the suitable one.
  • Click on the Field Type dropdown menu and select from Single Element or List.
    • Single Element: Use it for storing only a single value. For example fields such as title, description, price, etc can have only one value. You can't have multiple titles for a single post.
    • List: Use it for storing multiple values of the same data type. For example, to store the list of accessory names for the field accessories, Set the Data Type to String and Field Type to List.
  • Click on Create.
For our example, add the following fields to your todos collection:
  • Title, String, Single Element
  • Date, Timestamp, Single Element
  • Items, String, Single Element
  • IsDone, Boolean, Single Element

Sub-Collections

Creating sub-collections is not currently supported in FlutterFlow. However, anything that's possible with sub-collections can also be done using high-level collections + references. We follow that principle as "best practice" internally, and it does make querying easier in FlutterFlow.
Last modified 1mo ago