Create a new Flutter app.

Replace the lib/main.dart file with main.dart.

Replace the pubspec.yaml file with pubspec.yaml.

Create an images directory in your project, and add
lake.jpg.

Once you have a connected and enabled device,
or you’ve launched the iOS simulator
(part of the Flutter install) or the
Android emulator (part of the Android Studio
install), you are good to go!

Step 1: Decide which object manages the widget’s state

A widget’s state can be managed in several ways,
but in our example the widget itself,
FavoriteWidget, will manage its own state.
In this example, toggling the star is an isolated
action that doesn’t affect the parent widget or the rest of
the UI, so the widget can handle its state internally.

Learn more about the separation of widget and state,
and how state might be managed, in Managing state.