Skip to main content
The movies providers expose paginated List<Movie> state using Riverpod’s NotifierProvider. Every list-based provider shares the same MoviesNotifier class and differs only in which repository method it calls.

Provider overview


List providers

Each of the five list providers is declared with NotifierProvider and created with a MoviesNotifier that captures its specific fetch callback.
movies_providers.dart

Derived providers

movieSlideShowProvider

A read-only Provider<List<Movie>> that derives its value from nowPlayingMoviesProvider. It returns an empty list while now-playing movies are loading, otherwise it returns the first six entries for use in a hero slideshow.
movie_slideshow_provider.dart

intialLoadingProvider

A read-only Provider<bool> that returns true as long as any of the five movie lists is still empty. Widgets use this to show a full-screen loading indicator before the first page of data arrives.
initialLoading_provider.dart

MoviesNotifier

MoviesNotifier extends Riverpod’s Notifier<List<Movie>>. It accumulates pages of movies into its state list and guards against concurrent fetches with the isLoading flag.
movies_providers.dart

Fields

int
default:"0"
Tracks the last page number that was successfully fetched. Incremented before each API call inside loadNextPage().
bool
default:"false"
Guard flag that prevents duplicate in-flight requests. Set to true at the start of loadNextPage() and back to false once the fetch completes.

Methods

build()

Called once by Riverpod when the notifier is first read. Resolves the fetchMoreMovies callback from the _callbackBuilder closure (which has access to ref) and returns an empty list as the initial state.

loadNextPage()

Appends the next page of movies to state. If a fetch is already in progress (isLoading == true), the call returns immediately. Otherwise it increments currentPage, awaits the API call, and spreads the results onto the existing state list.

Usage in a widget

Call loadNextPage() once on first build (or when the user scrolls to the bottom) by reading the notifier from ref.
home_screen.dart
All providers are exported from lib/presentation/providers/providers.dart. Import that barrel file instead of individual provider files.