AgPagedService<T, PageKeyType extends Object> mixin

Gives a Service the getPage that AgListController.fetchPage needs, implemented once by the framework rather than hand-written per module.

This is the piece whose absence used to break consistency: with no framework-owned paging, every paginated collection dropped out of the declarative Service shape and hand-rolled its own query parameters, decoding, and hasMore arithmetic — so no two modules looked alike, and each one silently encoded its backend's quirks in imperative code.

Backend differences are absorbed by two declared values instead: pageStrategy (paging dialect) and envelope (where the payload sits in the response). A Service using this mixin contains no request plumbing at all:

class PostsService extends AgBaseService
    with AgCrudService<Post, int>, AgPagedService<Post, int> {
  PostsService(super.apiProvider);

  @override
  AgEndpoint get collectionEndpoint => PostEndpoints.posts;
  @override
  AgEndpoint get resourceEndpoint => PostEndpoints.postById;
  @override
  AgPageStrategy<int> get pageStrategy =>
      const AgPageNumberStrategy(pageParam: '_page', sizeParam: '_limit');
  @override
  Post fromJson(Map<String, dynamic> json) => Post.fromJson(json);
  @override
  Map<String, dynamic> toJson(Post item) => item.toJson();
}

Composes with AgCrudService — both declare collectionEndpoint and fromJson, which the class satisfies once. Use this alone for a read-only paginated list, AgCrudService alone for a resource that isn't a list, or both together for the usual collection module.

Superclass constraints

Properties

apiProvider → ApiProvider
finalinherited
collectionEndpoint → AgEndpoint
The collection endpoint pages are read from — no path parameters.
no setter
envelope → AgEnvelope
Where the payload sits inside this backend's response bodies. Defaults to "the body is the payload" — correct for most REST APIs.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
pageQueryParams → Map<String, dynamic>
Extra query parameters sent with every page request — a category filter, a search term, a sort order. Merged with (and overridden by) whatever pageStrategy contributes.
no setter
pageStrategy → AgPageStrategy<PageKeyType>
How this backend paginates.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

decodeItemPayload<D>(Object? body, D fromJson(Map<String, dynamic> json)) → D
Unwraps body via envelope and decodes the resulting JSON object with fromJson.
inherited
decodeListPayload<D>(Object? body, D fromJson(Map<String, dynamic> json)) → List<D>
Unwraps body via envelope and decodes the resulting JSON array with fromJson.
inherited
fetchItem<D>(AgRequest request, D fromJson(Map<String, dynamic> json)) → Future<D>
Sends request and decodes the response as a single object — the one-liner every feature-specific "fetch one" method should be.
inherited
fetchList<D>(AgRequest request, D fromJson(Map<String, dynamic> json)) → Future<List<D>>
Sends request and decodes the response as a list — the one-liner every feature-specific "fetch many" method should be.
inherited
fromJson(Map<String, dynamic> json) → T
Decodes a single item.
getPage(PageKeyType pageKey) → Future<AgListPage<T, PageKeyType>>
Fetches one page. Wire this straight into AgListController.fetchPage.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send<D>(AgRequest request, {D decode(Object? json)?}) → Future<AgResponse<D>>
Sends request through the shared ApiProvider.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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