The UI in this recipe is data-driven. The ListView widget (the view) queries the Plan class (the model) to figure out how many items there are. In the itemBuilder closure, we extract the specific Task that matches the item index and pass the entire model to the buildTaskTile method.
The Tiles are also data-driven as they read the complete boolean value in the model to choose whether the checkbox should be checked or not.
If you look at our implementation of the Checkbox widget, you'll see that it takes data from the model and then returns data to the model when its state changes. This widget is truly a view into our data:
Checkbox(
value: task.complete,
onChanged: (selected) {
setState(() {
task.complete = selected;
});
}),
When building the UI for each individual task, the State of these widgets is owned by the model. The UI's job is to query the model for its current state...