Flutter — State Management with Riverpod

Application State

Provider

Riverpod

The death of StatefulWidget

Too simple

Types or Providers

  • Provider — A provider that provides a read only value
  • StateProvider — A provider thats value can be modified from outside
  • StreamProvider — A provider that creates a stream and exposes it latest event
  • FutureProvider — A provider that asynchronously provides a single value
  • More .. go learn about them here

Dependency Injection

What’s going on here?

  • So we have a Movie data class, a MoviesRepo , and a MoviesApi
  • I created three providers, one for the api, one for the repo, and the last to hold the list of movies
  • The widget knows nothing about where the data comes from, just that it will receive a list of movies
  • The repo gets the api it needs from reading the moviesApiProvider.

Testing

--

--

--

Flutter Fan Boy & Android Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using Python to scrape and perform ETL to analyze factors influencing the purchasing behavior of…

BitTorrent File System(BTFS) 2.0.1 Testnet — Fisher is now live

Azure IoT in General

Currying in the real world

How I resolved PHP strtotime() of not working with 24-hour time format

NIKHIL’S JOURNEY FROM PYTHON TO POLYGLOT

Trueface Visionbox: faster, more accurate, and more secure

Benefits of Using Laravel For Your Next Project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tony Owen

Tony Owen

Flutter Fan Boy & Android Developer

More from Medium

A Framework for Flutter

Elementary: a New Approach to Architecture in Flutter Apps

State Management in Flutter.

Article image.

Flutter — Native commun with Pigeon