CenterPagingList<PageKey, Value> class

A widget that displays a paginated list with a center anchor point.

Unlike PagingList, this widget uses CustomScrollView's center key feature to anchor the initial content at a specific position. This allows for seamless bi-directional infinite scrolling:

  • Prepend items appear above the center (scrolling up reveals them)
  • Append items appear below the center (scrolling down reveals them)

This is particularly useful for scenarios like:

  • Chat interfaces where new messages appear at the bottom
  • Timeline views where you want to start at a specific point
  • Any list where bi-directional loading from a center point is desired
Inheritance

Constructors

CenterPagingList({Key? key, required CenterDataSource<PageKey, Value> dataSource, required TypedWidgetBuilder<Value> builder, ExceptionWidgetBuilder? errorBuilder, Widget? initialLoadingWidget, Widget? emptyWidget, required Widget prependLoadStateBuilder(BuildContext context, bool hasMore, bool isLoading), required Widget appendLoadStateBuilder(BuildContext context, bool hasMore, bool isLoading), EdgeInsets padding = EdgeInsets.zero, bool autoLoadPrepend = true, bool autoLoadAppend = true, Axis scrollDirection = Axis.vertical, bool reverse = false, ScrollController? controller, bool? primary, ScrollPhysics? physics, ScrollBehavior? scrollBehavior, bool shrinkWrap = false, ScrollCacheExtent? scrollCacheExtent, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, Clip clipBehavior = Clip.hardEdge})
Creates a CenterPagingList.
const
CenterPagingList.separated({Key? key, required CenterDataSource<PageKey, Value> dataSource, required TypedWidgetBuilder<Value> builder, ExceptionWidgetBuilder? errorBuilder, Widget? initialLoadingWidget, Widget? emptyWidget, required Widget prependLoadStateBuilder(BuildContext context, bool hasMore, bool isLoading), required Widget appendLoadStateBuilder(BuildContext context, bool hasMore, bool isLoading), EdgeInsets padding = EdgeInsets.zero, bool autoLoadPrepend = true, bool autoLoadAppend = true, Axis scrollDirection = Axis.vertical, bool reverse = false, ScrollController? controller, bool? primary, ScrollPhysics? physics, ScrollBehavior? scrollBehavior, bool shrinkWrap = false, ScrollCacheExtent? scrollCacheExtent, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, Clip clipBehavior = Clip.hardEdge, required IndexedWidgetBuilder separatorBuilder})
Creates a CenterPagingList with separators between items.
const

Properties

appendLoadStateBuilder → Widget Function(BuildContext context, bool hasMore, bool isLoading)
A builder for the append loading state widget.
final
autoLoadAppend → bool
Automatically load more data at the end of the list when reaching the boundary.
final
autoLoadPrepend → bool
Automatically load more data at the beginning of the list when reaching the boundary.
final
builder → TypedWidgetBuilder<Value>
A builder that creates a widget for each item in the list.
final
clipBehavior → Clip
The content will be clipped (or not) according to this option.
final
controller → ScrollController?
An object that can be used to control the position to which this scroll view is scrolled.
final
dataSource → CenterDataSource<PageKey, Value>
The CenterDataSource that provides the paginated data.
final
dragStartBehavior → DragStartBehavior
Determines the way that drag start behavior is handled.
final
emptyWidget → Widget?
The widget to display when the list is empty.
final
errorBuilder → ExceptionWidgetBuilder?
A builder that creates a widget to display when an error occurs.
final
hashCode → int
The hash code for this object.
no setterinherited
initialLoadingWidget → Widget?
The widget to display while the first page is being loaded.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardDismissBehavior → ScrollViewKeyboardDismissBehavior
Defines how this ScrollView will dismiss the keyboard automatically.
final
padding → EdgeInsets
The amount of space by which to inset the children.
final
physics → ScrollPhysics?
How the scroll view should respond to user input.
final
prependLoadStateBuilder → Widget Function(BuildContext context, bool hasMore, bool isLoading)
A builder for the prepend loading state widget.
final
primary → bool?
Whether this is the primary scroll view associated with the parent PrimaryScrollController.
final
reverse → bool
Whether the scroll view scrolls in the reading direction.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scrollBehavior → ScrollBehavior?
A ScrollBehavior that will be applied to this widget individually.
final
scrollCacheExtent → ScrollCacheExtent?
The cache extent of the scroll view.
final
scrollDirection → Axis
The axis along which the scroll view scrolls.
final
shrinkWrap → bool
Whether the extent of the scroll view in the scrollDirection should be determined by the contents being viewed.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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