The Complete Flutter Course: Build Android, iOS and Web Apps
Flutter state management, from setState up
State is whatever can change while an app runs: a count, a colour, whether a post is open. Most confusion starts with changing a value and seeing nothing happen. This guide gathers the lessons of The Complete Flutter Course: Build Android, iOS and Web Apps that build the idea up, from setState inside one widget to state shared with Provider and Riverpod.
Taught by Sagnik Bhattacharya and Paulina Knop
What you will be able to do
You will be able to:
- Tell stateless from stateful widgets, and change a screen with setState.
- Keep state that belongs to one widget, such as whether a post is open, inside that widget.
- Explain when setState is no longer enough and state has to be shared.
- Share a value with Provider and ChangeNotifier, and rebuild only the widgets that show it with Consumer.
- Watch state with Riverpod's ref.watch, and let autoDispose reset what no screen is using.
Projects
What you will build.
The course has nine projects. These two matter most here.
-
Project 01
My Dashatar
State inside one widget: a tap counter, random colours and a beat on every tap.
-
Project 06
Counter with Provider and Riverpod
State shared across widgets, built twice so the two packages can be compared line by line.
Lessons
The lessons that matter, in course order.
The Complete Flutter Course: Build Android, iOS and Web Apps has 223 lessons. This page picks out 10 of them, 50 min of video. Each lesson keeps its number in the course.
Where to start
Lesson 38 Stateful vs stateless widgets
Start at Lesson 38, which changes My Dashatar, built from Lesson 13. If setState is second nature, go to Lesson 153 for why apps need more, then on to Provider and Riverpod.
10 of 223 lessons · 50 min
07 State management - Basics State on My Dashatar: stateful against stateless, a tap counter with setState, random background colours, and a beat from the audioplayers package on each tap.
- 38 Start here Stateful vs stateless widgets What state is, then a tap counter on Dash with setState 5 min
- 39 Random background colours with setState Swap colours on tap, then pick from a list with Random 7 min
- 40 Add sound files and the audioplayers package Assets in pubspec.yaml, pub.dev checks and an AudioPlayer 4 min
- 41 Playing the beats Play on each tap and pick a random beat with an IconButton 4 min
14 Blog and Works Page - Flutter Portfolio A blog post's headline and an IconButton that opens or closes it by flipping a bool with setState.
- 116 Blog post headline and expand button An IconButton that flips the expand bool with setState 4 min
20 Advanced State management Why apps need state management, MVC and MVVM at a glance, then a counter with Provider and ChangeNotifier and again with Riverpod.
- 153 Introduction to advanced state management Why apps need it, MVC and MVVM at a glance, and Dart mixins 8 min
- 154 Provider and the counter starter project A view and view model split for a simple counter app 2 min
- 155 A counter with Provider and ChangeNotifier ChangeNotifierProvider, Consumer and notifyListeners 5 min
- 156 Riverpod, the successor to Provider ProviderScope and an autoDispose ChangeNotifierProvider 4 min
- 157 A counter with Riverpod and ConsumerWidget WidgetRef, ref.watch and when autoDispose resets state 5 min
Instructors
Who teaches it.
Instructor, Flutter
Paulina Knop
Flutter developer and curriculum designer. Teaches the Flutter course.
Questions
Asked before starting.
Which course explains Flutter state management from the beginning?
The Complete Flutter Course: Build Android, iOS and Web Apps from Coding Liquids starts from what state is, with a stateful My Dashatar whose counter, colour and sound change through setState. It then keeps state inside one reusable post widget, explains why bigger apps need more, and builds one counter with Provider and again with Riverpod. This guide picks out 10 lessons (50 minutes) on that thread; it is not the place for GetX, MobX or Redux.
Why does my screen not update when I change a variable?
Because Flutter redraws a widget only when told to. Changing a field in a StatefulWidget's state shows nothing until the change is made inside setState, which marks the widget to be built again, and a stateless widget has no setState to call. The Complete Flutter Course: Build Android, iOS and Web Apps shows this on a tap counter at Lesson 38, the first time My Dashatar holds state.
When is setState enough, and when do I need a package?
setState is enough while the state belongs to one widget, such as whether one blog post is expanded. Once several widgets in different places need the same value, passing it down by hand gets messy, and a package such as Provider or Riverpod holds it in one place. The Complete Flutter Course: Build Android, iOS and Web Apps explains that turning point at Lesson 153, before building the counter with each.
What does notifyListeners do, and why do widgets rebuild?
A ChangeNotifier calls notifyListeners after it changes a value, and every widget listening to it, through Provider's Consumer or Riverpod's ref.watch, is built again with the new value. Only those widgets rebuild, not the whole screen. The Complete Flutter Course: Build Android, iOS and Web Apps wires this up with ChangeNotifierProvider, Consumer and notifyListeners at Lesson 155.
What is autoDispose, and when does state reset?
autoDispose is a Riverpod modifier that throws a provider's state away once no widget is watching it, so the next screen to read it starts fresh. That saves memory but surprises people who expected a value to survive leaving a screen. The Complete Flutter Course: Build Android, iOS and Web Apps adds it at Lesson 156 and shows when it resets the counter at Lesson 157.
Are InheritedWidget and ValueNotifier explained too?
No. The Complete Flutter Course: Build Android, iOS and Web Apps does not teach InheritedWidget, ValueNotifier, GetX, MobX or Redux. Provider, which it does teach, is itself a wrapper around InheritedWidget, so you meet the idea through it; Flutter's own documentation covers the built-in tools if you want to see what lies underneath.
Flutter
See the whole course.
The Complete Flutter Course: Build Android, iOS and Web Apps: 25 hours of video in 223 lessons, built around 9 projects, with lifetime access, a Certificate of Completion and a 14-day money-back guarantee.
The same course
For another background, goal, topic or comparison.
By background
By goal
By topic
- Dart
- Firebase
- Widgets and layouts
- UI design and styling
- Riverpod
- App architecture
- Sign-in and authentication
- Cloud Firestore
- REST APIs with Dio
- Navigation and routing
- Responsive layouts
- Animations and gestures
- Flutter web
- Set-up on Windows and Mac
- Forms and validation
- Futures and Streams
- CI with GitHub Actions
- Reusable widgets
- Debugging
- Packages from pub.dev
Comparisons
- Flutter or React Native
- Which framework to learn
- Course or free tutorials
- Flutter or native Android
- Flutter or Swift
- Flutter or Kotlin Multiplatform
- Flutter or FlutterFlow
- Learn Flutter or use AI
- Riverpod, BLoC or Provider
- Firebase or Supabase
- Flutter web or React
- Dart or JavaScript
- Flutter or Ionic
- Flutter or .NET MAUI
- VS Code or Android Studio