Aggregates
The dataset provides two aggregate paths: immediate aggregates over the current loaded flat view, and query aggregates for the full logical result set when paging is involved.
Current-view aggregates
final count = dataSet.aggregates.count();
final total = dataSet.aggregates.sum('amount');
final average = dataSet.aggregates.avg('amount');
final minimum = dataSet.aggregates.min('amount');
final maximum = dataSet.aggregates.max('amount');
Numeric sum() and avg() use FdcDecimal semantics rather than floating-point accumulation.
Query aggregates
For paged adapter-backed data, the loaded page is not the whole logical result. Use calculate() when the aggregate must cover all rows matching the active query:
final result = await dataSet.aggregates.calculate([
const FdcDataAggregateItem(
fieldName: 'amount',
aggregate: FdcAggregate.sum,
),
]);
In paged mode, the adapter calculates over the full filtered and searched result set without applying page limit or offset.
Choose the right path
Use current-view aggregate helpers when you intentionally want values over rows currently held by the dataset. Use query aggregates when the user expects totals for the complete logical query result.
This distinction is especially important for page summaries and status bars.