The parent widget manages the widget’s state

Often it makes the most sense for the parent widget
to manage the state and tell its child widget when to update.
For example, IconButton allows you to treat
an icon as a tappable button. IconButton is a
stateless widget because we decided that the parent
widget needs to know whether the button has been tapped,
so it can take appropriate action.

In the following example, TapboxB exports its state
to its parent through a callback. Because TapboxB
doesn’t manage any state, it subclasses StatelessWidget.

The ParentWidgetState class:

Manages the _active state for TapboxB.

Implements _handleTapboxChanged(),
the method called when the box is tapped.

When the state changes, calls setState()
to update the UI.

The TapboxB class:

Extends StatelessWidget because all state is handled by its parent.