PrismPaginatedList<T> class
Infinite-scroll list with built-in pagination states.
Give it a pageLoader that fetches one page at a time (page starts at
0) and an itemBuilder; the list handles everything else:
- first-load spinner and full-screen error with retry
- automatic load-more when the user scrolls near the end
- footer spinner / retryable error / "no more items" end marker
- empty-state widget when the first page returns nothing
- refresh via
RefreshIndicator
PrismPaginatedList<Post>(
pageLoader: (page) => api.fetchPosts(page),
itemBuilder: (context, post, index) => PostTile(post),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PrismPaginatedList
Constructors
-
PrismPaginatedList({Key? key, required Future<
List< pageLoader(int page), required Widget itemBuilder(BuildContext context, T item, int index), WidgetBuilder? emptyBuilder, Widget errorBuilder(BuildContext context, VoidCallback retry)?, WidgetBuilder? loadingBuilder, String retryLabel = 'Retry', String noMoreLabel = 'No more items', int pageSizeHint = 20, ScrollPhysics? physics, EdgeInsetsGeometry padding = EdgeInsets.zero})T> > -
Creates a paginated list.
const
Properties
- emptyBuilder → WidgetBuilder?
-
Shown when the first page is empty. Defaults to a centered
"No more items" text.
final
- errorBuilder → Widget Function(BuildContext context, VoidCallback retry)?
-
Shown when the first page fails to load. Receives a retry callback.
final
-
Footer text shown when loading more items fails.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemBuilder → Widget Function(BuildContext context, T item, int index)
-
Builds a row for item
itemat absolute indexindex.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → WidgetBuilder?
-
Shown while the first page loads. Defaults to a centered spinner.
final
- noMoreLabel → String
-
Footer text shown once all pages have been loaded.
final
- padding → EdgeInsetsGeometry
-
Padding around the list.
final
-
pageLoader
→ Future<
List< Function(int page)T> > -
Fetches page
page(0-based). Return an empty list to signal the end of the data set. Throw to surface an error state.final - pageSizeHint → int
-
Rough number of items per page — used only to size the scroll
pre-trigger. Adjust if your rows are very tall.
final
- physics → ScrollPhysics?
-
Scroll physics for the inner list.
final
- retryLabel → String
-
Footer retry button label.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PrismPaginatedList< T> > -
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