Skip to main content

Paging

Paging is adapter-driven. The dataset requests rows with an offset and limit while preserving the same filter, sort, search, and aggregate model used elsewhere.

Enable standard paging

final dataSet = FdcDataSet(
fields: fields,
adapter: adapter,
paging: const FdcDataPagingOptions(
enabled: true,
pageSize: 100,
requireTotalCount: true,
),
);

await dataSet.open();

Standard paging replaces the loaded rows when another page is opened.

await dataSet.paging.firstPage();
await dataSet.paging.priorPage();
await dataSet.paging.nextPage();
await dataSet.paging.lastPage();

Open an arbitrary zero-based page index:

await dataSet.paging.openPage(4);

Inspect paging state

final pageIndex = dataSet.paging.pageIndex;
final pageSize = dataSet.paging.pageSize;
final pageCount = dataSet.paging.pageCount;
final total = dataSet.paging.totalRecordCount;
final hasNext = dataSet.paging.hasNextPage;

pageCount and exact total record information require the adapter to report a total count.

Change page size

await dataSet.paging.setPageSize(250);

Changing page size reloads from the first page and validates against the configured maximum.

Infinite paging

Configure infinite mode when sequential next-page loads should append rows instead of replacing the current page:

final dataSet = FdcDataSet(
fields: fields,
adapter: adapter,
paging: const FdcDataPagingOptions(
enabled: true,
pageSize: 100,
mode: FdcDataPagingMode.infinite,
infiniteLoadThreshold: 0.70,
),
);

Infinite paging keeps the adapter contract unchanged. Sequential next-page loads append records to the retained dataset view.

UI code that specifically controls incremental loading can use:

if (dataSet.paging.hasNextPage &&
!dataSet.paging.isLoadingNextPage) {
await dataSet.paging.loadNextPage();
}

Query operations restart paging correctly

Filtering, sorting, and searching are logical query operations. In paged mode they are applied through the adapter path so page boundaries are rebuilt from the new query rather than modifying only the currently loaded rows.