Skip to main content

Memory adapter

FdcMemoryDataAdapter stores rows in memory and supports the normal dataset query surface, including filtering, sorting, searching, paging, total counts, aggregates, and selected-key filtering.

final adapter = FdcMemoryDataAdapter(
rows: const [
{
'id': 1,
'company': 'Cascade Coffee',
'city': 'Portland',
'state': 'OR',
},
{
'id': 2,
'company': 'Lakeview Market',
'city': 'Chicago',
'state': 'IL',
},
],
);

final customers = FdcDataSet(
fields: const [
FdcIntegerField(name: 'id', isKey: true),
FdcStringField(name: 'company', size: 120),
FdcStringField(name: 'city', size: 80),
FdcStringField(name: 'state', size: 2),
],
adapter: adapter,
);

await customers.open();

Updating the source rows

The adapter exposes a defensive copy through rows and can replace its complete source with replaceRows():

adapter.replaceRows(updatedRows);
await customers.open();

Replacing adapter rows does not implicitly reopen the dataset. Reopen when the visible dataset should reflect the new source.

Local query behavior

Dataset filters and sorts are evaluated against the memory rows. Paging still follows the same dataset contract, which makes the memory adapter useful for testing screens before connecting a remote or SQLite backend.

Editing

The memory adapter is writable. Dataset apply operations update its internal source rows, so it is suitable for complete local CRUD examples and automated tests.

Large local row sets

For smaller sources, queries run inline. For sufficiently large row sets, the adapter can execute query work in a background isolate while preserving the same public API.