Tip:
  Placing the Text in a SizedBox and setting its
  width prevents a discernible “jump” when the text changes
  between the values of 40 and 41 — a jump would
  otherwise occur because those values have different widths.

The _toggleFavorite() method, which is called when the
IconButton is pressed, calls setState().
Calling setState() is critical, because this
tells the framework that the widget’s state has
changed and that the widget should be redrawn.
The function argument to setState() toggles the
UI between these two states:

A star icon and the number 41

A star_border icon and the number 40

Step 4: Plug the stateful widget into the widget tree

Add your custom stateful widget to the widget tree in
the app’s build() method. First, locate the code that
creates the Icon and Text, and delete it.
In the same location, create the stateful widget: