flutter_pagination_pro 0.4.0
flutter_pagination_pro: ^0.4.0 copied to clipboard
Flutter pagination: generic page keys (int, cursor, offset), infinite scroll, load more button, grid view, slivers, numbered pagination, controlled mode, updateFetchPage for search/filter, built-in lo [...]
Changelog #
0.4.0 #
New Features #
-
Skeleton / Shimmer first-page loading:
DefaultFirstPageLoading.builder()— a named constructor that renders a list of placeholder widgets during the initial load. AcceptsitemBuilder,itemCount(default 6), optionalseparatorBuilder,padding, andscrollDirection. Works seamlessly as afirstPageLoadingBuilderfor shimmer/skeleton patterns without adding any dependencies. -
Header & Footer convenience parameters: Both
PaginationListViewandPaginationGridView(all 3 constructors) now accept optionalheaderandfooterwidgets. The header scrolls above the paginated items; the footer scrolls below all items. Internally switches toCustomScrollViewwhen either is provided — transparent to the user. -
Testing utilities (
package:flutter_pagination_pro/testing.dart):testPaginationController<K, T>()— creates a pre-seeded controller with known state for fast, deterministic widget tests.- Custom matchers:
hasItemCount(n),isOnPage(key),hasStatus(status),isPaginationCompleted,hasPaginationError([error]),isPaginationEmpty. - Separate entry point — import
testing.dartin test files only.
Dependencies #
- Added
matcher(^0.12.0) as a dependency for the testing utilities custom matchers. This package is already a transitive dependency offlutter_testin every Flutter project.
0.3.0 #
Breaking Changes #
- Generic page keys (
K): All controllers and widgets now require two type parameters:PaginationController<K, T>,PaginationListView<K, T>, etc. whereKis the page key type andTis the item type. For integer pages, use<int, T>or the new convenience aliases. FetchPage<T>→FetchPage<K, T>: The fetch callback now receivesK pageKeyinstead ofint page.OnPageLoaded<T>→OnPageLoaded<K, T>: The page-loaded callback now providesK pageKeyinstead ofint page.PaginationState.currentPage→PaginationState.pageKey: Theint currentPagefield is replaced byK? pageKey.PaginationConfig.initialPageremoved: UseinitialPageKeyon the controller or widget constructor instead.
New Features #
initialPageKeyis optional for int keys: WhenKisint,initialPageKeydefaults to1— you no longer need to pass it for the common case.- Convenience typedefs:
PagedListView<T>,PagedGridView<T>,PagedController<T>,SliverPagedList<T>,SliverPagedGrid<T>— these alias the<int, T>variants so you can writePagedListView<User>(...)instead ofPaginationListView<int, User>(...). - Cursor-based pagination: Use
PaginationController<String, T>withnextPageKeyBuilder: (_, items) => items.last.cursorfor cursor/token-based APIs. - Offset-based pagination: Use
PaginationController<int, T>withinitialPageKey: 0andnextPageKeyBuilder: (offset, items) => offset + items.length. updateFetchPage(): Replace the data source at runtime — ideal for search/filter scenarios. Cancels any ongoing fetch, resets state, and reloads from the first page.- Controlled mode (
.controlled()constructors): All four widget types (PaginationListView,PaginationGridView,SliverPaginatedList,SliverPaginatedGrid) now support a.controlled()named constructor for BYO state management — provide items, status, and callbacks directly without aPaginationController. NextPageKeyBuilder<K, T>typedef: New callback type for computing the next page key from the current key and loaded items. Defaults to(k, _) => k + 1forintkeys.
Migration Guide (0.2.0 → 0.3.0) #
// Before (0.2.0)
PaginationController<User>(fetchPage: (page) => api.getUsers(page: page));
PaginationListView<User>(fetchPage: (page) => ..., itemBuilder: ...);
// After (0.3.0) — simplest with aliases
PagedController<User>(fetchPage: (page) => api.getUsers(page: page));
PagedListView<User>(fetchPage: (page) => ..., itemBuilder: ...);
// After (0.3.0) — explicit generic form (also valid)
PaginationController<int, User>(fetchPage: (page) => api.getUsers(page: page));
PaginationListView<int, User>(fetchPage: (page) => ..., itemBuilder: ...);
0.2.0 #
New Features #
pageSizeauto last-page detection: SetpageSizeinPaginationConfigto automatically detect the final page when fewer items than expected are returned — eliminates phantom "loading more" spinners.initialItemssupport: Prepopulate the list with cached data viaPaginationController(initialItems: [...]). The controller starts inloadedstate, skipping the initial load.totalItems/setTotalItems: Track the total item count from your API. Callcontroller.setTotalItems(total)to display "Showing X of Y" and auto-complete when all items are loaded.findChildIndexCallbackpassthrough: All scroll widgets (PaginationListView,PaginationGridView,SliverPaginatedList,SliverPaginatedGrid) now acceptfindChildIndexCallbackfor improved performance during item mutations.
Improvements #
PaginationConfignow supportspageSizefield with proper==/hashCode/copyWith.PaginationStatenow includestotalItemsfield with proper==/hashCode/copyWith/toString.
0.1.0 #
Breaking Changes #
PaginationConfig: ReplacedinvisibleItemsThresholdwithscrollThreshold(in pixels, default 200.0) for clearer, more accurate scroll-triggered loading.onPageLoaded: Now fires with only the new items loaded on that page instead of the full accumulated list.PaginationGridView: Removed unusedmainAxisSpacingandcrossAxisSpacingparameters (they were accepted but never applied). Set spacing viagridDelegateinstead.
Bug Fixes #
- Refresh no longer wipes the screen:
controller.refresh()now keeps existing items visible while reloading, instead of replacing everything with a full-page loading spinner. DefaultLoadMoreErrornow shows the actual error: Previously hardcoded "Failed to load more" and ignored theerrorfield.
New Features #
- Sliver variants: Added
SliverPaginatedListandSliverPaginatedGridfor use insideCustomScrollView, enabling composability withSliverAppBar,SliverToBoxAdapter, and other slivers. - Pull-to-refresh: Added
enablePullToRefreshparameter toPaginationListViewandPaginationGridView. - Accessibility: Added semantic labels to
NumberedPaginationbuttons for screen readers. NumberedPaginationConfig: Added==andhashCodefor proper equality comparison.
Improvements #
- Shared pagination mixin: Extracted
PaginationStateMixinto eliminate code duplication betweenPaginationListViewandPaginationGridView. - Config from controller: When using
.withController(), config is now read from the controller instead of widget defaults. - Fixed README: Corrected parameter tables to match actual API.
0.0.1 #
Initial release.
Features #
- PaginationListView - ListView with pagination support
- PaginationGridView - GridView with pagination support
- NumberedPagination - Page number navigation widget
- PaginationController - Programmatic control for pagination
Pagination Modes #
- Infinite Scroll - Auto-load when scrolling near bottom
- Load More Button - Manual button to load next page
- Numbered - Classic page number navigation
Highlights #
- Zero external dependencies
- Fully customizable UI components
- Built-in loading, error, and empty states
- Type-safe generic API
- Separator support for ListView