This page describes how to update document data of Firestore collection.
Updating allows you to make changes to a single document. For example, you could display the Todo details on a new page and allow users to update any Todo information. Just like the following visual:
Updating Todo item
Showing and updating document data consists of the following steps:
First, let's design a page that allows you to update the Todo details:
- Create/Select a page and give it a name.
- Select the AppBar widget and remove the existing back button. Move to the property editor (on the right) and turn on the Show Default Button.
- Inside the Column widget, add a TextField (under Form Elements) to show the Todo title and give it a name such as TextFieldTitle.
- Add another TextField inside a Column to show the Todo Description and give it a name such as TextFieldDescription.
- Add a Button to save changes.
Building a page
Before you allow users to update any data, you must display it on the screen.
To show data in the TextField widget:
- Select the TextField Widget from the widget tree or from the canvas area.
- Move to property editor and scroll down to the Initial Value property.
- Click on the Set from Variable text. (This will open a new panel)
- Find the Source dropdown, click on unset and select the source. For showing data from the Parameter, select the Parameter Name which holds the record.
- Under the Available Options, click on Unset and select the field that you wish to show.
- Click Save.
- Similarly, show the data for other UI elements as well.
Show data in UI elements