InfiniteList class
A widget that makes it easy to declaratively load and display paginated data as a list.
When the list is scrolled to the end, the onFetchData callback will be called.
When there are too few items to fill the widget's allocated space, onFetchData will be called automatically.
The itemCount, hasReachedMax, onFetchData and itemBuilder must be
provided and cannot be null
.
{@endtemplate}
See also:
- SliverInfiniteList. The sliver version of this widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- InfiniteList
Constructors
- InfiniteList({required int itemCount, required VoidCallback onFetchData, required ItemBuilder itemBuilder, Key? key, ScrollController? scrollController, Axis scrollDirection = Axis.vertical, ScrollPhysics? physics, double? cacheExtent, Duration debounceDuration = defaultDebounceDuration, bool reverse = false, bool isLoading = false, bool hasError = false, bool hasReachedMax = false, EdgeInsets? padding, WidgetBuilder? emptyBuilder, WidgetBuilder? loadingBuilder, WidgetBuilder? errorBuilder, IndexedWidgetBuilder? separatorBuilder, bool centerLoading = false, bool centerError = false, bool centerEmpty = false})
-
const
Properties
- cacheExtent → double?
-
See RenderViewportBase.cacheExtent
final
- centerEmpty → bool
-
Indicates if the emptyBuilder should be centered.
final
- centerError → bool
-
Indicates if the errorBuilder should be centered.
final
- centerLoading → bool
-
Indicates if the loadingBuilder should be centered.
final
- debounceDuration → Duration
-
The duration with which calls to onFetchData will be debounced.
final
- emptyBuilder → WidgetBuilder?
-
An optional builder that's shown when the list of items is empty.
final
- errorBuilder → WidgetBuilder?
-
{@template error_builder}
An optional builder that's shown when hasError is not
null
.final - hasError → bool
-
Indicates if an error has occurred.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasReachedMax → bool
-
Indicates if the end of the data source has been reached and no more
data can be fetched.
final
- isLoading → bool
-
Indicates if new items are currently being loaded.
final
- itemBuilder → ItemBuilder
-
The builder used to build a widget for every index of the
itemCount
.final - itemCount → int
-
The amount of items that need to be rendered by the itemBuilder.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → WidgetBuilder?
-
An optional builder that's shown at the end of the list when isLoading
is
true
.final - onFetchData → VoidCallback
-
The callback method that's called whenever the list is scrolled to the end
(meaning the top when reverse is
true
, or the bottom otherwise).final - padding → EdgeInsets?
-
The amount of space by which to inset the list of items.
final
- physics → ScrollPhysics?
-
An optional ScrollPhysics to be used by the internal ScrollView.
final
- reverse → bool
-
Indicates if the list should be reversed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
An optional ScrollController to be used by the internal ScrollView.
final
- scrollDirection → Axis
-
An optional Axis to be used by the internal ScrollView that defines
the axis of scroll.
final
- separatorBuilder → IndexedWidgetBuilder?
-
An optional builder that, when provided, is used to show a widget in
between every pair of items.
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}) → 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