Skip to main content

Persist user layouts

Layout persistence lets users return to their preferred grid organization without coupling the grid to one storage technology.

1. Choose a stable storage key

Use a key that identifies the screen and layout scope, for example:

orders.main-grid.v1

Include a version suffix when future schema changes may require a new layout namespace.

2. Configure persistence

FdcProGrid(
dataSet: orders,
layoutPersistence: FdcGridLayoutPersistence(
autoLoad: true,
autoSave: true,
load: loadOrdersGridLayout,
save: saveOrdersGridLayout,
delete: deleteOrdersGridLayout,
),
)

The application owns storage. The callbacks can use device storage, a preferences service, a database, or a remote user-profile API.

3. Debounce automatic writes

FdcGridLayoutPersistence(
autoSave: true,
autoSaveDelay: const Duration(milliseconds: 500),
save: saveOrdersGridLayout,
)

This avoids writing on every intermediate layout change while the user is resizing or rearranging the grid.

4. Provide a reset action

await controller.resetLayout();

Reset restores the configured default layout and deletes the stored snapshot through the persistence feature.

Storage design recommendations

Keep layout state separate from business data. Treat it as user preference data.

For shared accounts or multi-device experiences, scope the storage key by user and screen. For local desktop applications, device-local storage is often enough.

See Layout Persistence for the feature reference.