CRUD Operations
The dataset exposes a compact CRUD lifecycle around the current record. Grid and editor interactions use the same underlying operations as application code.
Edit a record
dataSet.edit();
dataSet['name'] = 'Updated name';
dataSet['status'] = 'active';
dataSet.post();
edit() creates the editable buffer for the current record. post() validates and posts those values into dataset state.
Append a record
dataSet.append();
dataSet['name'] = 'New customer';
dataSet['status'] = 'active';
dataSet.post();
append() creates a new record at the end of the dataset view.
Insert a record
dataSet.insert();
dataSet['name'] = 'Inserted customer';
dataSet.post();
insert() creates a new record at the current position rather than appending at the end.
Cancel an edit
dataSet.edit();
dataSet['name'] = 'Temporary value';
dataSet.cancel();
cancel() discards the active edit buffer. It does not discard changes that were already posted earlier.
Delete the current record
dataSet.delete();
Deletion follows the configured update mode. With cached updates, the deletion remains part of the pending change set until updates are applied or canceled.
Immediate and cached updates
The default update mode is immediate:
final dataSet = FdcDataSet(
fields: fields,
adapter: adapter,
);
Use cached updates when a screen needs an explicit save boundary:
final dataSet = FdcDataSet(
fields: fields,
adapter: adapter,
updateMode: FdcUpdateMode.cachedUpdates,
);
Then apply all posted changes explicitly:
final result = await dataSet.applyUpdates();
Or discard all pending posted changes:
dataSet.cancelUpdates();
The distinction between cancel() and cancelUpdates() is important: one cancels the current edit buffer; the other rolls back the accumulated cached update set.