PagingController<PageKeyType, ItemType> class

A controller for a paged widget.

If you modify the itemList, error or nextPageKey properties, the paged widget will be notified and will update itself appropriately.

The itemList, error or nextPageKey properties can be set from within a listener added to this controller. If more than one property need to be changed then the controller's value should be set instead.

This object should generally have a lifetime longer than the widgets itself; it should be reused each time a paged widget constructor is called.

Inheritance

Constructors

PagingController({required PageKeyType firstPageKey, int? invisibleItemsThreshold})
PagingController.fromValue(PagingState<PageKeyType, ItemType> value, {required PageKeyType firstPageKey, int? invisibleItemsThreshold})
Creates a controller from an existing PagingState.

Properties

error ↔ dynamic
The current error, if any. Initially null.
getter/setter pair
firstPageKey → PageKeyType
The key for the first page to be fetched.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
invisibleItemsThreshold int?
The number of remaining invisible items that should trigger a new fetch.
final
itemList List<ItemType>?
List with all items loaded so far. Initially null.
getter/setter pair
nextPageKey ↔ PageKeyType?
The key for the next page to be fetched.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value PagingState<PageKeyType, ItemType>
The current value stored in this notifier.
getter/setter pairinherited-getteroverride-setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addPageRequestListener(PageRequestListener<PageKeyType> listener) → void
Calls listener every time new items are needed.
addStatusListener(PagingStatusListener listener) → void
Calls listener every time the status of the pagination changes.
appendLastPage(List<ItemType> newItems) → void
Appends newItems to the previously loaded ones and sets the next page key to null.
appendPage(List<ItemType> newItems, PageKeyType? nextPageKey) → void
Appends newItems to the previously loaded ones and replaces the next page's key.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
notifyPageRequestListeners(PageKeyType pageKey) → void
Calls all the page request listeners.
notifyStatusListeners(PagingStatus status) → void
Calls all the status listeners.
refresh() → void
Resets value to its initial state.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removePageRequestListener(PageRequestListener<PageKeyType> listener) → void
Stops calling the listener every time new items are needed.
removeStatusListener(PagingStatusListener listener) → void
Stops calling the listener every time the status of the pagination changes.
retryLastFailedRequest() → void
Erases the current error.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited