State in Flutter
Minimum price
Suggested price

State in Flutter

A Guide to State Management in Flutter

About the Book

If I say, StafulWidget in Flutter is actually a StatelessWidget, you'll get confused!


If I had said, stateful widget didn't make any sense, either you wouldn't have agreed, or you would have got more confused!

Hope this book will help you to be a Better Flutter Developer who can manage state and make her Flutter App more performant. However, for state management always use the latest Provider Package, and maintain Null Safety.

I also strongly recommend to read the latest Flutter blog at my website.

Let me tell you the truth. The stateful widget, although might come to help for a tiny app where we need to change a single class property, doesn't really make any sense for a big, complex flutter app.

Why not? Because it unnecessarily rebuilds the widgets resulting in huge memory usage.

The best solution to manage state, so far, is Provider. However, very recently Riverpod, a modified version of Provider has been gaining popularity, since it does not depend on Flutter anymore and can work independently.

In this book I have explained every bits and pieces of state management in Flutter, so you no longer get confused about state management anymore.

I also help you to understand the mechanism involved inside this confusion. How Flutter uses a separate State object and actually makes stateful Widget immutable or stateless?

This book discusses that topic and more.

The first question that comes to mind is, then what is State in Flutter?

Is that a Widget too? Or a Class? Type? Object?

In this book we've discussed State in a great detail.

If you're an intermediate learner or advanced professional who are still struggling with the complex concept of State in Flutter, then this book is for you!

This book has shown how to manage State efficiently. How to make your Flutter app more performant.

To have more confidence you need to understand the concept of Inherited Widget and how Provider package as a Wrapper class uses that concept too!

And I've discussed that too in great detail.

  • Share this book

  • Categories

    • Computers and Programming
    • Software
    • Software Architecture
    • Android
    • iOS
    • Software Engineering
  • Installments completed

    19 / 19

  • Feedback

    Email the Author(s)

About the Author

Sanjib Sinha
Sanjib Sinha

A Freak, in an absurd journey that starts from nowhere, and ends up nowhere.

Bundles that include this book

Bought separately
Bundle Price

Table of Contents

  • 1. Getting Started
    • Download Latest Flutter
    • Who should read this book?
    • Many options to manage State in Flutter
    • Flutter for Windows
    • Flutter for macOS and Linux
  • 2. What is the difference between stateless widget and stateful widget in Flutter?
    • What is stateless widget in Flutter?
    • Stateless widget flutter Example
    • What is build method in Flutter?
    • How do you rebuild widgets in Flutter?
    • When Should I call setState Flutter?
  • 3. What is callback in Flutter? How do you pass a function in Flutter?
    • What is callback?
    • What is callback in Flutter?
    • How do you call widgets in Flutter?
  • 4. What is a map in Flutter? How do you map a list in Flutter?
    • What is the key concept of State Management in Flutter?
    • What is a map in Flutter?
    • How do you map a list in Flutter?
  • 5. Why is state management in Flutter? What is flutter state?
    • How we change the widget state in Flutter?
    • How to manage state of child through parent widget?
    • How do you use stateful widget Flutter?
    • How a Child Widget exports its state to its parent
    • How Child Widget implements this special property?
    • How the export and import of state take place
  • 6. How many types of widgets are there in Flutter?
    • What are visible widgets?
    • What are the widgets in Flutter?
    • How do I create a Custom widget in Flutter?
  • 7. What is inherited widget in Flutter, how do you use state management?
    • What is InheritedWidget in Flutter?
    • How do you manage state efficiently?
    • InheritedWidget manages state efficiently, but is that all?
    • How do you use an inherited widget in Flutter?
    • We keep our inherited widgets in a separate folders
    • How do you manage state through inherited widgets?
    • Extending state management to the second uncle and his child
  • 8. What is flutter provider? How does provider flutter work?
    • Why we need a Model?
  • 9 . How do you use Provider Consumer to manage State in Flutter?
    • How do you use Provider Consumer?
    • What is the Problem in managing state in Flutter?
    • How Flutter helps us to manage State?
    • How could we notify Listeners?
    • The Specific Steps to use Consumer widget
  • 10. How do you use onPressed in flutter?
    • How do you use onPressed in flutter?
    • How do you call a function in flutter?
    • What is flutter function?
    • What is callback in flutter?
  • 11. Provider: A recommended approach to manage State
    • Ephemeral State or Single Widget is not enough
    • Different approaches to state management
    • A Step by Step guide to use Provider
    • Multi Providers and Multi Models
  • 12. How to Organize Flutter Code, Model-View-Controller Patterns
    • The Role of Model
    • The role of Controller
    • The Role of View
  • 13. ChangeNotifier and Provider context read and watch, when to use and how to use
    • How can I improve my fluttering performance?
    • How to avoid the anti-pattern and stick to the correct design pattern in Flutter?
    • How have we got rid of widget rebuild in Flutter?
    • How do you change the state in Flutter?
    • What is ChangeNotifier?
    • What is the difference between stateful and stateless widget in Flutter?
    • What does provider do in Flutter?
    • Provider helps you to avoid rebuilding widgets
  • 14. Provider best practices: How to reduce widget rebuilds
    • How do you use a provider in Flutter?
    • When do I use stateful widget? Or, should I?
    • How does stateful widget rebuild the whole tree?
    • Model, View, Controller and Provider
    • Model folder has three classes
    • The Second Row Widget will listen to the Name Change Model
    • Third Row Widget listens to Name Clear Model
    • Finally the view folder and main method
    • Here comes our Home Page
  • 15. Riverpod, a better Provider for state management
    • Riverpod has many options
    • The greatest advantage of Riverpod
    • The Data Model on which we’ll work in Riverpod
    • Understanding Riverpod Scope
    • How to watch a Provider object in Riverpod?
    • How we can mix Riverpod Provider with old Provider package?
    • The old Provider package is really gold!
  • 16. Riverpod ChangeNotifierProvider Widget and why it is important to autodispose
    • ChangeNotifierProvider in Provider package
    • What is autodispose and why it is important?
    • How to wrap a state object in a Riverpod Provider?
  • 17. StateProvider in Riverpod, another Provider variant that makes State Management Simple
    • What is StateProvider in Riverpod?
    • App structure and segments
    • StateProvider provides the state object
    • Where Riverpod differs with the Package Provider?
    • The controller widgets that build the business logic
    • The data model of StateProvider
    • How to read a StateProvider in Riverpod?
    • There are multiple ways to read the StateProvider
    • Watching the StateProvider
    • Watch and Read the final StateProvider of our Flutter app
    • Model to Controller to View
  • 18. What is StateNotifier and StateNotifierProvider in Riverpod Flutter? How it reduces Widget Rebuilds?
    • Data model of StateNotifierProvider
    • The watch() and read() of StateNotifierProvider
    • The relation between StateNotifierProvider and StateNotifier, a complex app structure
    • How StateNotifierProvider reduces widget rebuilds?
    • What does StateNotifierProvider in Riverpod mean?
    • What kind of state we need to notify and provide?
    • More you break, your code becomes more readable and maintanable
    • How HomeStateNotifierProvider listens to NameNotifier
    • How CartNotifierProvider listens to CartNotifier
  • 19. Riverpod migration, WidgetRef ref, and What is new in Riverpod
    • Why we need the latest Flutter and Dart SDK?
    • Is Riverpod better than Provider?
    • What is a WidgetRef?
    • Model class with StateNotifierProvider in new Riverpod
  • 20. What Next

Causes Supported

Amazon Watch

Supporting Indigenous Peoples. Protecting the Amazon.

Amazon Watch is a nonprofit organization founded in 1996 to protect the rainforest and advance the rights of indigenous peoples in the Amazon Basin. We partner with indigenous and environmental organizations in campaigns for human rights, corporate accountability and the preservation of the Amazon's ecological systems.

We envision a world that honors and values cultural and biological diversity and the critical contribution of tropical rainforests to our planet's life support system. We believe that indigenous self-determination is paramount, and see that indigenous knowledge, cultures and traditional practices contribute greatly to sustainable and equitable stewardship of the Earth. We strive for a world in which governments, corporations and civil society respect the collective rights of indigenous peoples to free, prior and informed consent over any activity affecting their territories and resources. We commit, in the spirit of partnership and mutual respect, to support our indigenous allies in their efforts to protect life, land, and culture in accordance with their aspirations and needs.

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub