PaginatedResponse<T> class

Wraps a page of items with pagination metadata (page number, totals) and provides factory parsing from JSON.

Key names are overridable. Set them once at bootstrap when the backend uses its own names:

PaginatedResponse.configure(
  const PaginatedResponseKeys(
    items: ['results'],
    totalCount: ['count'],
  ),
);

or per-call via the keys parameter of PaginatedResponse.fromJson.

Constructors

PaginatedResponse({required List<T> items, required int pageNumber, required int pageSize, required int totalCount, required int totalPages})
const
PaginatedResponse.fromJson(Map<String, dynamic> json, T fromJsonT(Map<String, dynamic>), {PaginatedResponseKeys? keys})
factory

Properties

data List<T>
no setter
hashCode int
The hash code for this object.
no setterinherited
hasNextPage bool
no setter
hasPreviousPage bool
no setter
isEmpty bool
no setter
items List<T>
final
length int
no setter
pageNumber int
final
pageSize int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalCount int
final
totalPages int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

keys PaginatedResponseKeys
Global default keys applied by PaginatedResponse.fromJson.
no setter

Static Methods

configure(PaginatedResponseKeys keys) → void