Fireship · @fireship
Flutter State Management - The Grand Tour
Uploaded March 12, 2019 · Length 14:07
Summary
Flutter State Management - The Grand Tour: 10 ways to build a basic counter app using different state management strategies in Flutter.
- flutter state management
- flutter state management strategies
- flutter counter app
- flutter stateful widget
- flutter stateless widget
- flutter inherited widget
- flutter behavior subject
- flutter rx dart
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
state management for whatever reason is
- 0:09
a topic that brings out strong opinions
- 0:10
and developers I'm gonna have to go
- 0:17
ahead and sort of disagree with you
- 0:18
there in today's video we'll look at 10
- 0:20
different ways to build a basic counter
- 0:22
app using different state management
- 0:23
strategies employer we'll also just talk
- 0:25
about what state management is and why
- 0:27
there are so many different ways to
- 0:28
approach it and hopefully by the end of
- 0:29
this video you know exactly where
- 0:31
strategy is ideal for your app if you're
- 0:33
new here like and subscribe and you grab
- 0:34
the full source code on fire ship IO and
- 0:36
I'm giving away another t-shirt with
- 0:38
this video just leave me a comment with
- 0:39
your own opinions about state management
- 0:41
below first of all what is stake in a
- 0:43
reactive framework like flutter you can
- 0:45
think of your UI as the return value of
- 0:47
a function that function gets called
- 0:48
with one argument which is your state so
- 0:51
state is just data that changes over the
- 0:53
lifecycle of your app a lot of your data
- 0:55
can be self-contained within a single
- 0:56
widget that's known as local state we'll
- 0:59
look at the tools that we have built
- 1:00
into flutter to manage local state which
- 1:01
is pretty straightforward things get
- 1:03
interesting when we start talking about
- 1:04
global state or state that needs to be
- 1:06
shared throughout the widget tree coming
- 1:08
from the web development world I've seen
- 1:09
tons of debate over state management and
- 1:11
a lot of apps over engineered with these
- 1:13
big state management libraries that
- 1:15
didn't really need them that's not to
- 1:16
say they're not valuable but even the
- 1:18
creators and maintainer of those
- 1:19
libraries will tell you that you
- 1:20
probably don't need them we'll talk
- 1:22
about the pros and cons of these various
- 1:23
libraries as we go but for now let's
- 1:25
focus on the fundamental building blocks
- 1:27
in flutter starting with the stateful
- 1:29
widget when you run flutter create from
- 1:30
the command line it gives you some
- 1:32
starter code that increments a counter
- 1:33
with a stateful widget we're going to
- 1:35
rebuild this counter multiple times
- 1:37
throughout this video using different
- 1:38
state management strategies to create a
- 1:40
stateful widget we need two classes the
- 1:42
first one is the stateful widget itself
- 1:44
and that implements a create state
- 1:46
method and that returns our second class
- 1:48
which is an extension of the state class
- 1:50
and this is where all the heavy lifting
- 1:52
happens first we define a property
- 1:54
called counter which is an integer that
- 1:56
defines the actual data state of this
- 1:57
widget then we define a method called
- 1:59
increment counter and it calls a method


