PaginatedItemsResponse<T> class

The response object that carries the list of items and handles pagination internally if paginationKey is specified.

Available extensions

Constructors

PaginatedItemsResponse({required String idGetter(T), required Iterable<T>? listItems, required dynamic paginationKey, int? itemsPerPage})
Creates a response holding one page of results.
PaginatedItemsResponse.empty({required String idGetter(T), int? itemsPerPage})
Creates an empty response, for holding a response object before the first page has been fetched. Merge pages into it with update.

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasMoreData → bool
Whether there is more data that can be loaded.
no setter
idGetter → String Function(T)
Returns the unique id of an item of type T.
final
isEmpty → bool
True when there are no items.
no setter
isNotEmpty → bool
True when there is at least one item.
no setter
items → List<T>
The items held, in the order they arrived.
final
itemsPerPage → int?
How many items make up a full page, for APIs that page by size rather than by cursor.
final
length → int
The number of items held.
no setter
paginationKey ↔ dynamic
The pagination key. Can be null.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clear the contents.
findByUid(String id) → T?
Find an object by id. Returns null if there is no such item.
log() → void
Logs the response.
merge(PaginatedItemsResponse<T> newResponse, {bool reset = false}) → PaginatedItemsResponse<T>

Available on PaginatedItemsResponse<T>?, provided by the PaginatedItemsResponseMerge extension

Merges newResponse into this response and returns the result.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
update(PaginatedItemsResponse<T> res) → void
Updates the response, merging in the items of res and adopting its pagination key.
updateItem(String itemUid, T? item, {bool addIfDoesNotExist = false}) → void
update a specific item with uid, or add if does not exists according to addIfDoesNotExist.
updateItems(Iterable<T> newItems, {bool addIfDoesNotExist = true}) → void
Update many items at once, replacing any whose id already exists and appending the rest according to addIfDoesNotExist.

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](int index) → T
operator []=(int index, T value) → void