StaleMatePaginatedLoader<ListItemType, HandlerType extends PaginatedHandlerMixin<ListItemType> > class
A StaleMateLoader that supports pagination.
This loader is useful when you have data that needs to be loaded in pages.
The StaleMatePaginatedLoader supports everything that the StaleMateLoader supports, and adds the ability to load paginated data.
- In contrast to the base StaleMateLoader, the StaleMatePaginatedLoader only supports lists, and takes in T as a data type, where T is the type of the list items.
Additions to base StaleMateLoader:
- handler must use PaginatedHandlerMixin
- paginationConfig is required and it is used to load the data in pages.
- fetchMore method is added to fetch more data from the server.
See also:
- StaleMatePaginationConfig
- StaleMatePagePagination
- StaleMateOffsetLimitPagination
- StaleMateCursorPagination
- StaleMateFetchMoreResult
Example:
final loader = MyPaginatedLoader(
paginationConfig: StaleMatePagePagination(
pageSize: 10,
zeroBasedIndexing: false,
);
handler: MyPaginatedHandler(),
);
// Load the first page of data
await loader.initialize();
// Fetch more data
final result = await loader.fetchMore();
result.on(
success: (mergedData, newData, isDone) {
// Datat is already in the data stream
// Do something with the data if needed
},
failure: (error) {
// Do something with the error
},
);
- Inheritance
-
- Object
- StaleMateLoader<
List< ListItemType> , HandlerType> - StaleMatePaginatedLoader
Constructors
-
StaleMatePaginatedLoader({required StaleMatePaginationConfig<
ListItemType> paginationConfig, required HandlerType handler, bool updateOnInit = true, bool showLocalDataOnError = true, StaleMateRefreshConfig? refreshConfig, StaleMateLogLevel? logLevel}) - Create a new StaleMatePaginatedLoader instance
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the data stream is currently empty
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showLocalDataOnError → bool
-
Whether or not the local data should be shown when an error occurs
finalinherited
- state → StaleMateLoaderState
-
Indicates what the current state of the data loader is
no setterinherited
-
stream
→ Stream<
List< ListItemType> > -
Returns the stream of the data
no setterinherited
- updateOnInit → bool
-
Whether or not the data should be updated when the data loader is initialized
finalinherited
-
value
→ List<
ListItemType> -
Returns the current value of the data
no setterinherited
Methods
-
addData(
List< ListItemType> data) → Future<void> -
Adds the data to the data stream
inherited
-
addStateListener(
StateListener listener) → void -
Adds a state listener to the data loader
inherited
-
close(
) → dynamic -
Closes the loader
inherited
-
fetchMore(
) → Future< StaleMateFetchMoreResult< ListItemType> > - Fetch more data from the server
-
initialize(
) → Future< void> -
Initializes the loader
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< StaleMateRefreshResult< List< >ListItemType> > -
Refreshes the data
inherited
-
removeStateListener(
StateListener listener) → void -
Removes a state listener from the data loader
inherited
-
reset(
) → Future< void> -
Resets the loader
override
-
setLogLevel(
StaleMateLogLevel logLevel) → void -
Sets the log level of the loader
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited