Skip to main content
Related data

Flutter master-detail grids with independent DataSets

Keep parent and child records independent—and coordinated. Each dataset retains its own schema, validation, cursor, adapter, and record lifecycle.

PRO PREVIEWPreview of Flutter Data Components Pro

This capability belongs to flutter_data_components_pro and is documented as a preview. It is not currently available from the Community package on pub.dev.

MASTER RELATION

Represent the relationship without flattening the records.

The parent dataset owns customers, invoices, projects, or another primary entity. The child dataset owns orders, lines, tasks, or events. Each dataset keeps the fields and rules that actually belong to its records.

A master relation constrains child loading from the current parent key. Moving the parent cursor changes the child view, but it does not erase the child dataset’s own editing, validation, paging, or persistence contract.

final customers = FdcDataSet(
fields: customerFields,
adapter: customerAdapter,
);

final orders = FdcDataSet(
fields: orderFields,
adapter: orderAdapter,
masterDataSet: customers,
masterRelation: const [
FdcMasterDetailRelation(
masterField: 'customer_id',
detailField: 'customer_id',
),
],
);
DETAIL ROWS

Open the child workflow directly beneath its parent row.

An FdcGridDetailRow is a regular Flutter content surface attached to a stable source-row context. It can show a child grid, form, report, chart, document preview, or application-specific controls without navigating away from the parent list.

The detail grid can use different columns, row height, menus, summaries, and editing rules. Expansion may be single or multiple, content-sized or fixed-height, and controlled by the user or application code.

FdcProGrid(
dataSet: customers,
detailRow: FdcGridDetailRow(
singleExpanded: true,
detailHeight: null,
builder: (context, row) {
return CustomerOrders(
customerId: row.value<int>('customer_id')!,
);
},
),
)
COORDINATED LIFECYCLES

Child operations can affect the parent without merging both models.

Posting or deleting a child record may change the parent’s revenue, count, last activity date, status, or another derived value. Handle that coordination explicitly after the child lifecycle completes, while both datasets remain independently testable.

Remote relationships also need stale-result protection. When the user moves or expands another parent before a child request returns, only the result for the active relationship should become visible.

afterPost: (orders) {
customers.edit();
customers.setFieldValue(
'revenue',
orders.aggregates.sum('total'),
);
customers.post();
},
PRO PREVIEW

Explore the Pro capability in the documentation.

Review the current API and interaction model while Pro distribution is being prepared.