When the user taps the list item, the widget doesn’t modify
its inCart value directly. Instead, the widget calls the
onCartChanged function it received from its parent widget.
This pattern lets you store state higher in the widget
hierarchy, which causes the state to persist for longer periods of time.
In the extreme, the state stored on the widget passed to
runApp() persists for the lifetime of the
application.

When the parent receives the onCartChanged callback,
the parent updates its internal state, which triggers
the parent to rebuild and create a new instance
of ShoppingListItem with the new inCart value.
Although the parent creates a new instance of
ShoppingListItem when it rebuilds, that operation is cheap
because the framework compares the newly built widgets with the previously
built widgets and applies only the differences to the underlying
RenderObject.

Here’s an example parent widget that stores mutable state:

StatefulWidget,
which means this widget stores mutable state.
When the