Firestore
The Firestore action allows you to create, update or delete a record from a Firestore Collection.

Creating, updating, and deleting a Todo item
Before getting started with this section:
There are three types of actions you can perform on a Firestore document.
- 1.
- 2.
- 3.
Go to your project page on FlutterFlow and follow the steps below to define the Action to any widget.
- Select the Widget (e.g. Button) on which you want to define the action.
- Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
- Click on + Add Action.
- On the right side, search and select the Firestore action and then select Create Record.
- Set the Collection to your collection name (e.g. todo).
- Under the Set Fields section, click on the + Field button.
- Click on the Field name.
- Scroll down to find the Value Source dropdown and change it to From Variable.
- Find the Source dropdown and change it to Widget State.
- Find the Available Options dropdown and set it to the Name of the TextField.
- Similarly, add the field for the other UI elements such as description and date.

Defining Create Document Action
Now, when a user taps the Add button when running the app, it will create a document in a collection.

Adding record
Go to your project page on FlutterFlow and follow the steps below to define the Action to any widget.
- Select the Widget (e.g. Button) on which you want to define the action.
- Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
- Click on + Add Action.
- On the right side, search and select the Firestore -> Update Record action.
- Set the Source to the Parameter Name that holds the record.
- Set the Available Options to reference.
- Under the Set Fields section, click on the + Add Field button.
- Click on the Field name.
- Scroll down to find the Value Source dropdown and change it to From Variable.
- Find the Source dropdown and change it to Widget State.
- Find the Available Options dropdown and set it to the Name of the TextField.
- Similarly, add the field for the other UI elements such as description and date.

Defining Update Document action
The following visual demonstrates updating the record:

Updating record
Go to your project page on FlutterFlow and follow the steps below to define the Action to any widget.
- Select the Widget (e.g. Button) on which you want to define the action.
- Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
- Click on + Add Action.
- On the right side, search and select the Firestore -> Delete Record action.
- Set the Source to the [collection] Record (from ListView).
- Set the Available Options to reference.
- Click Close.

Defining Delete Document action
The following visual demonstrates deleting the record:

Deleting record
FlutterFlow uses the cloud_firestore package to interact with the Firestore Database, to know more about how the CRUD operations are performed using this package check out their Docs.
Last modified 3mo ago