Skip to main content

Connect to SQLite

Use FdcSqliteTableAdapter when a dataset maps directly to a writable SQLite table.

1. Define the dataset

final customers = FdcDataSet(
fields: const [
FdcIntegerField(name: 'customer_id', isKey: true),
FdcStringField(name: 'company', size: 120),
FdcStringField(name: 'city', size: 80),
FdcStringField(name: 'state', size: 2),
],
adapter: FdcSqliteTableAdapter(
databasePath: databasePath,
table: 'customers',
sorts: const [
FdcDataAdapterSort(
fieldName: 'company',
sortType: FdcSortType.ascending,
),
],
),
paging: const FdcDataPagingOptions(
enabled: true,
mode: FdcDataPagingMode.standard,
pageSize: 100,
),
);

2. Open the dataset

await customers.open();

The dataset now coordinates filtering, sorting, paging, and writes through the adapter.

3. Bind the grid

FdcProGrid(
dataSet: customers,
columns: const [
FdcIntegerColumn(fieldName: 'customer_id', label: 'ID'),
FdcTextColumn(fieldName: 'company', label: 'Company'),
FdcTextColumn(fieldName: 'city', label: 'City'),
FdcTextColumn(fieldName: 'state', label: 'State'),
],
)

Query-backed screens

For dashboards and reports that return read-only SQL result sets, use FdcSqliteQueryAdapter.

Use the wrappable constructor only when the SELECT can safely be wrapped as a subquery and every projected value has a stable alias matching the FDC field name.

See SQLite Adapters for the adapter variants and lifecycle details.