Structure
Provider setup
Repository provider
The entry point for dependency injection ismovieRepositoryProvider. It wires together the concrete datasource and repository, producing the single MoviesRepository instance used throughout the app.
MoviesRepository abstraction.
MoviesNotifier and pagination
MoviesNotifier is a generic Notifier<List<Movie>> that manages an append-only list of movies. The same class powers every movie category by accepting a different callback at construction time.
currentPagestarts at0and increments before each request, so the first call always fetches page1isLoadingacts as a guard — callingloadNextPage()while a request is in flight is a no-op- New results are spread-appended to the existing state list, triggering a widget rebuild
Category providers
Each movie category gets its ownNotifierProvider. They all share MoviesNotifier but are configured with a different repository method:
The
_callbackBuilder pattern lets MoviesNotifier remain reusable across all five categories without subclassing. The callback is resolved lazily inside build() so that ref is available at the right lifecycle moment.Home screen
HomeScreen is the main entry point for the app. It delegates all rendering to its internal _HomeView widget.
_HomeView is a ConsumerStatefulWidget so it can call providers in initState to trigger the initial page load for all five categories:
Infinite scroll pattern
EachMovieHorizontalListview receives a loadNextPage callback. When the user scrolls to the end of a horizontal list, the widget calls the callback, which invokes loadNextPage() on the corresponding notifier. The notifier increments currentPage, fetches the next batch, and appends it to state — causing the list to grow without replacing existing items.