createPaginatedController<T, Q> function

AutoDisposeNotifierProvider<PaginatedSearchController<T, Q>, PaginatedState<T, Q>> createPaginatedController<T, Q>({
  1. required SearchProvider<T, Q> searchProvider,
  2. int pageSize = PaginatedSearchController.defaultPageSize,
  3. Duration debounceDuration = PaginatedSearchController.defaultDebounceDuration,
  4. Q? initialQuery,
  5. bool debugLoggingEnabled = true,
})

Create a paginated controller provider easily. For example

final recipesPaginatedControllerProvider = createPaginatedController(searchProvider: RecipesSearchProvider());

This would simplify your controller creation and make your code easier to read.

Implementation

AutoDisposeNotifierProvider<PaginatedSearchController<T, Q>, PaginatedState<T, Q>>
    createPaginatedController<T, Q>({
  required SearchProvider<T, Q> searchProvider,
  int pageSize = PaginatedSearchController.defaultPageSize,
  Duration debounceDuration = PaginatedSearchController.defaultDebounceDuration,
  Q? initialQuery,
  bool debugLoggingEnabled = true,
}) {
  return NotifierProvider.autoDispose(
    () => PaginatedSearchController<T, Q>(
      searchProvider: searchProvider,
      pageSize: pageSize,
      debounceDuration: debounceDuration,
      initialPageQuery: initialQuery,
      debugLoggingEnabled: debugLoggingEnabled,
    ),
  );
}