PaginatedListView<T, E> class
A drop-in ListView that handles pagination automatically.
Attach it to an ApiPaginator and it will:
- Render items with itemBuilder
- Show a shimmer / loading indicator while the first page loads
- Show an empty view when there are no results
- Append a per-page loader at the bottom while fetching the next page
- Trigger
paginator.loadNext()when the user scrolls near the end
Example:
PaginatedListView<Gallery, ApiError>(
paginator: _paginator,
itemBuilder: (ctx, item) => GalleryCard(item),
loadingBuilder: () => const GalleryShimmer(),
emptyBuilder: () => const EmptyGalleries(),
errorBuilder: (msg) => ErrorView(msg, onRetry: _paginator.loadFirst),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PaginatedListView
Constructors
-
PaginatedListView({Key? key, required ApiPaginator<
T, E> paginator, required Widget itemBuilder(BuildContext context, T item), Widget loadingBuilder()?, Widget emptyBuilder()?, Widget errorBuilder(String message)?, Widget pageLoadingBuilder()?, double loadMoreThreshold = 0.9, ScrollPhysics? physics, EdgeInsetsGeometry? padding, ScrollController? scrollController, Widget separatorBuilder(BuildContext context, int index)?}) -
const
Properties
- emptyBuilder → Widget Function()?
-
Shown when the list is empty after a successful load
final
- errorBuilder → Widget Function(String message)?
-
Shown when an error occurs
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemBuilder → Widget Function(BuildContext context, T item)
-
Called for each item in the list
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → Widget Function()?
-
Shown while the very first page is loading
final
- loadMoreThreshold → double
-
Fraction of the scroll extent that triggers loadNext (default: 0.9 = 90%)
final
- padding → EdgeInsetsGeometry?
-
Padding for the inner ListView
final
- pageLoadingBuilder → Widget Function()?
-
Shown as a footer while subsequent pages are loading
final
-
paginator
→ ApiPaginator<
T, E> -
final
- physics → ScrollPhysics?
-
Physics for the inner ListView
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
Scroll controller (optional; one is created internally if omitted)
final
- separatorBuilder → Widget Function(BuildContext context, int index)?
-
Separator widget between items (uses ListView.separated when provided)
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PaginatedListView< T, E> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited