Intro to Riverpod

When you start building a new app in Flutter, you have some important decisions to make:

  • How to manage dependencies?
  • How to deal with asynchronous state?
  • How to make my widgets rebuild reactively when the data changes?

While building the Flutter Ship app, I faced the same challenges. And I knew that with some effort, I could have coded the app with the built-in Flutter state management widgets, along with a simple service locator such as get_it.

Riverpod addresses all of these concerns—and more—with ease:

  • Catch programming errors at compile-time, reducing runtime bugs.
  • Fetch and update data from remote sources with little effort.
  • Reactively cache state and update your UI automatically.
  • Handle asynchronous or computed state with ease.
  • Create, use, and combine providers with minimal boilerplate.
  • Automatically dispose of state when it’s no longer needed.
  • Write testable code and keep your logic outside the widget tree.

Instead of reinventing the wheel with Flutter’s vanilla state management and manually implementing these features, I opted for the battle-tested, robust solution that does all the heavy lifting for me.

Is Riverpod tough to learn?

Admittedly, it’s not easy to master Riverpod, but you don’t need to be a Riverpod expert to follow this course.

And to make life easier, this module will cover all the essential concepts and APIs, so you can follow along even if you have never used Riverpod before.

What we will cover

Think of this module as a Riverpod crash course, designed to get you up to speed. We’ll cover the essential concepts, basic syntax, and some best practices, so you can more easily understand how Riverpod is used in the course project.

Here’s what’s coming up:

  • Managing dependencies in Flutter with Riverpod
  • Riverpod installation and setup (including code generation)
  • Providers and Consumers: How to create and use them effectively
  • ref.watch vs ref.read: Understanding the difference
  • Asynchronous Providers: FutureProvider, StreamProvider, and AsyncValue
  • Passing Arguments to Providers (Families)
  • Notifiers and AsyncNotifiers: Managing state and side effects
  • Eager Provider Initialization and using requireValue
  • Provider Lifecycle and when to use keepAlive

Ready? Let’s go! 🚀

Resources

Questions? Let's chat