Create the base HomePage Layout
In this task, you will initialize the HomePage with an observable, set the values, create and update the layout in consequence.
Last updated
In this task, you will initialize the HomePage with an observable, set the values, create and update the layout in consequence.
Last updated
To see the Function, Preview and Delete buttons, hover the desired field.
In the Explorer section, select the HomePage top widget and in the Settings Panel, click on the Add button below Observables.
Fill the field Name with taskList.
Select Task as Field Type in the bottom of the dropdown, in the Custom type section.
Click on List.
The Observable is created as shown below.
Because we can store our Tasks in Local State, we have to initialize the observable taskList with the current values in the local state variable taskList.
Open the Action Flow Editor of HomePage.
Click on Add Action.
An Action 0 appears, click on it.
On the Define Action right panel, fill the Action Name with "setTaskList".
Select Set Observable as Type.
In Set Observable Source select the observable we have created on the HomePage taskList - (List<Task>).
Let the Update Type as Set Value because we are setting the observable with a value.
Select Local State instead of From Value in the dropdown.
The field below allows us to select which Local State we want to use, select taskList -> List<Task>.
Click on Save.
Now that the observable is created, and the HomePage initializes it with the stored values of the Local State. We have to create our layout.
In the Toolbox section, search and drag and drop a ListView in the Body of the Scaffold.
Add a Card in the Children of ListView.
Add a CheckboxListTile in the Child of Card.
Add a Text in the Title of CheckboxListTile.
Add a Column in the Subtitle of CheckboxListTile.
Add a Text, then a Row below it in the Children of Column.
Add a Flexible in the Children of Row.
Add a Text in the Child of Flexible.
Add an Icon and a Text below Flexible in Row.
Add an IconButton in the Secondary of CheckboxListTile.
Without any theming, naming and settings it should looks like shown below.
We have created a ListView with a defined layout for any item in it, now we have to set the Data Source of it with our taskList observable.
Click on ListView and in the Settings Panel, select the second tab, i.e the Generate Children From Variable tab.
Set the Type of the Data Source as List<Task>.
Change the From Value to Observable.
Select the taskList -> (List<Task>) in the list of observable.
Let the following field to empty, because we want a list of Task, and not a list of a property of Task like a list of the Title of all the Task.
Click on Save.
Now the ListView will be populated with the data from our observable. To have a visual preview, the list view shows in the Application Preview multiple items to perfect our layout.
When you Hover on the Update Source section, you can click on a button that appeared. It allows us to select a Source Value from dynamic fields.