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.

When total count is unknown, hasNextPage follows loaded-page evidence rather than exact page-count arithmetic. Adapter contracts should return fewer than pageSize rows at the end of an unknown-total sequence so the dataset can identify exhaustion correctly.

Refresh the current query

Reload the current paging query while keeping the current page when possible:

await dataSet.paging.refreshPage(
mode: FdcPageRefreshMode.keepPage,
);

Restart from the first page:

await dataSet.paging.refreshPage(
mode: FdcPageRefreshMode.firstPage,
);

Use keepPage for refresh commands where preserving user position matters. Use firstPage after a query-level change or workflow that should intentionally restart navigation.

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.

nextPage() is page navigation. In standard mode it replaces the visible page. In infinite mode, UI code that specifically owns incremental append behavior should prefer loadNextPage(), which exposes the guarded incremental-loading path and isLoadingNextPage state.

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.