InfiniteScrollFlow<T> class

A standalone infinite-scroll list with built-in pull-to-refresh.

Minimal usage

InfiniteScrollFlow<Post>(
  fetcher: (page, limit) => api.getPosts(page: page, limit: limit),
  itemBuilder: (context, post) => PostCard(post: post),
)

With a custom controller (so you can trigger refresh externally)

final _controller = InfiniteScrollController<Post>();

InfiniteScrollFlow<Post>(
  controller: _controller,
  fetcher: (page, limit) => api.getPosts(page: page, limit: limit),
  itemBuilder: (context, post) => PostCard(post: post),
)

// Somewhere else:
_controller.refresh(...);
Inheritance

Constructors

InfiniteScrollFlow({Key? key, required PageFetcher<T> fetcher, required Widget itemBuilder(BuildContext context, T item), int limit = 20, int prefetchOffset = 3, MoInfiniteScrollController<T>? controller, Widget? loadingPlaceholder, Widget? emptyPlaceholder, Widget? errorPlaceholder, Widget? loadingMoreIndicator, EdgeInsetsGeometry? padding, ScrollPhysics? physics, Widget separatorBuilder(BuildContext context, int index)?})
Creates an InfiniteScrollFlow.
const

Properties

controller MoInfiniteScrollController<T>?
Optional external controller. If not provided, the widget manages its own internal controller.
final
emptyPlaceholder Widget?
Widget shown when the list is empty after a successful fetch. Defaults to DefaultEmptyPlaceholder.
final
errorPlaceholder Widget?
Widget shown when a fetch throws an error. Defaults to DefaultErrorPlaceholder.
final
fetcher PageFetcher<T>
Called whenever a new page is needed.
final
hashCode int
The hash code for this object.
no setterinherited
itemBuilder Widget Function(BuildContext context, T item)
Builds a single item widget.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
limit int
Number of items to request per page. Passed directly to fetcher. Defaults to 20.
final
loadingMoreIndicator Widget?
Widget shown at the bottom of the list while loading more pages. Defaults to a centred CircularProgressIndicator.
final
loadingPlaceholder Widget?
Widget shown while the very first page is loading. Defaults to DefaultLoadingPlaceholder.
final
padding EdgeInsetsGeometry?
Padding applied to the underlying ListView.
final
physics ScrollPhysics?
Physics for the underlying ListView.
final
prefetchOffset int
How many items from the bottom of the list should trigger a pre-fetch. Defaults to 3.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
separatorBuilder Widget Function(BuildContext context, int index)?
Separator builder, mirroring ListView.separated.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<InfiniteScrollFlow<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