Skip to content

Engine API

Reference documentation for the engine layer: DashboardEngine, DashboardCommand, CommandHistory, event types, DashboardExtension, and DashboardEditorController.

DashboardEngine

Class Signature

Constructor Parameters

ParameterTypeRequiredDescription
initialLayoutDashboardLayout?NoStarting layout. If null, starts with DashboardLayout.empty(). Row flex values are normalized on construction.
registryDashboardEditorRegistry?NoRegistry used to resolve component instances. Defaults to an empty scoped registry.

Properties

PropertyTypeDefaultDescription
layoutObservableObservable<DashboardLayout>--Reactive layout state
layoutDashboardLayout--Current layout value
registryDashboardEditorRegistry--Component registry
extensionsList<DashboardExtension>--Unmodifiable list of extensions

Methods

  • addExtension
    void addExtension(DashboardExtension extension)

    Registers an extension. Throws StateError if an extension with the same ID is already registered.

  • removeExtension
    void removeExtension(String id)

    Removes an extension by ID.

  • getExtension returns E?
    E? getExtension<E extends DashboardExtension>()

    Returns the registered extension of type E if any.

  • hasExtension returns bool
    bool hasExtension(String id)

    Whether an extension with the given ID is registered.

  • executeCommand
    Future<void> executeCommand(DashboardCommand command)

    Executes a command, wrapping mutations in MobX runInAction and emitting events.

  • applyUndo
    Future<void> applyUndo(DashboardCommand command)

    Applies a previously executed command in reverse.

  • applyRedo
    Future<void> applyRedo(DashboardCommand command)

    Re-applies a previously undone command.

  • replaceLayout
    void replaceLayout(DashboardLayout newLayout)

    Normalizes flex values and replaces the layout. Emits DashboardLayoutChanged.

  • emitEvent
    void emitEvent(DashboardEvent event)

    Emits an event to all registered extensions.

  • batch
    void batch(String reason, void Function() operations)

    Emits DashboardBatchStarted/DashboardBatchEnded around a group of operations. Supports nesting.

  • dispose
    void dispose()

    Detaches all extensions and clears the list.

Mutation API

  • addRow
    Future<String> addRow({int? position})

    AddRowCommand: Adds a row, returns the new row ID.

  • removeRow
    Future<void> removeRow(String rowId)

    RemoveRowCommand: Removes a row.

  • reorderRow
    Future<void> reorderRow(int oldIndex, int newIndex)

    ReorderRowsCommand: Moves a row.

  • splitRow
    Future<void> splitRow(String rowId, int numColumns)

    SplitRowCommand: Replaces all columns with N equal columns.

  • addColumn
    Future<void> addColumn(String rowId)

    AddColumnCommand: Adds a column to a row.

  • removeColumn
    Future<void> removeColumn(String rowId, String columnId)

    RemoveColumnCommand: Removes a column.

  • reorderColumns
    Future<void> reorderColumns(String rowId, int oldIndex, int newIndex)

    ReorderColumnsCommand: Reorders columns within a row.

  • updateColumnFlex
    Future<void> updateColumnFlex({required String rowId, required String columnId, required int flex})

    UpdateColumnFlexCommand: Sets a single column flex value.

  • resizeAdjacentColumns
    Future<void> resizeAdjacentColumns({required String rowId, required String leftColumnId, required String rightColumnId, required int leftFlex, required int rightFlex})

    ResizeAdjacentColumnsCommand: Resizes two adjacent columns together.

  • updateRowFlex
    Future<void> updateRowFlex({required String rowId, required Map<String, int> flexByColumnId})

    UpdateRowFlexCommand: Sets all column flex values.

  • updateRowTitle
    Future<void> updateRowTitle({required String rowId, required String? title})

    UpdateRowTitleCommand: Sets or clears the title.

  • updateRowHeight
    Future<void> updateRowHeight({required String rowId, required double? height})

    UpdateRowHeightCommand: Sets the row height.

  • updateRowViewportFraction
    Future<void> updateRowViewportFraction({required String rowId, required double? viewportFraction})

    UpdateRowViewportFractionCommand: Sets the viewport-relative row height.

  • addComponent
    Future<void> addComponent({required String rowId, required String columnId, required ComponentInstance component})

    AddComponentCommand: Places a component in an empty column.

  • removeComponent
    Future<void> removeComponent({required String rowId, required String columnId})

    RemoveComponentCommand: Clears a column's component.

  • replaceComponent
    Future<void> replaceComponent({required String rowId, required String columnId, required ComponentInstance newComponent})

    ReplaceComponentCommand: Replaces one component with another.

  • swapComponents
    Future<void> swapComponents({required String sourceRowId, required String sourceColumnId, required String targetRowId, required String targetColumnId})

    SwapComponentsCommand: Swaps two components.

  • duplicateComponent
    Future<void> duplicateComponent({required String sourceRowId, required String sourceColumnId})

    DuplicateComponentCommand: Copies a component to the nearest empty slot.

  • updateComponentConfig
    Future<void> updateComponentConfig({required String componentId, required PropertyCollection newProperties})

    UpdateComponentConfigCommand: Updates a component's properties.

  • updateLayoutMetadata
    Future<void> updateLayoutMetadata(Map<String, dynamic> patch)

    UpdateDashboardMetadataCommand: Patches the dashboard metadata.

MobX-based state kernel for the dashboard system. Owns the reactive layout and emits structured events to extensions.


DashboardEngineApi

abstract

Class Signature

Forward declaration interface used by extensions to access the engine without circular imports.


DashboardCommand

abstract

Class Signature

Abstract interface for reversible commands.

Built-in Commands

Row Commands:

CommandDescription
AddRowCommandAdd a row at a specific position
RemoveRowCommandRemove a row and reorder remaining rows
ReorderRowsCommandMove a row from one position to another
SplitRowCommandReplace all columns with N equal columns
UpdateRowTitleCommandSet or clear the row title
UpdateRowHeightCommandSet the row height in pixels
UpdateRowViewportFractionCommandSet the viewport-relative row height

Column Commands:

CommandDescription
AddColumnCommandAdd an empty column to a row
RemoveColumnCommandRemove a column and normalize flex
ReorderColumnsCommandSwap column positions within a row
UpdateColumnFlexCommandChange a single column's flex value
ResizeAdjacentColumnsCommandResize two adjacent columns together
UpdateRowFlexCommandSet flex values for all columns in a row

Component Commands:

CommandDescription
AddComponentCommandPlace a component in an empty column
RemoveComponentCommandClear a column's component
ReplaceComponentCommandReplace one component with another
SwapComponentsCommandSwap components between two columns
DuplicateComponentCommandCopy a component to the nearest empty slot
UpdateComponentConfigCommandUpdate a component's PropertyCollection

Dashboard Commands:

CommandDescription
UpdateDashboardMetadataCommandMerge a patch into dashboard metadata

CommandHistory

Class Signature

Constructor Parameters

ParameterTypeRequiredDescription
maxHistorySizeintNoMaximum commands kept in history (default: 50)

Properties

PropertyTypeDefaultDescription
maxHistorySizeint--Maximum commands in history
canUndobool--Whether undo is available
canRedobool--Whether redo is available
currentCommandDashboardCommand?--Current undo target
nextCommandDashboardCommand?--Next redo target
historySizeint--Total commands in stack
currentPositionint--Current position (1-based)

Methods

  • execute
    void execute(DashboardCommand command)

    Adds a command and discards the redo stack.

  • undo returns DashboardCommand?
    DashboardCommand? undo()

    Moves back, returning the command that was undone.

  • redo returns DashboardCommand?
    DashboardCommand? redo()

    Moves forward, returning the command that was redone.

  • clear
    void clear()

    Clears all history.

Manages the undo/redo stack.


DashboardEvent Types

All events extend DashboardEvent:

dart
abstract class DashboardEvent { const DashboardEvent(); }
EventFieldsEmitted When
DashboardLayoutChangedprevious, current (both DashboardLayout)Layout observable is updated
DashboardCommandExecutedcommand (DashboardCommand)A command is first executed
DashboardCommandUndonecommand (DashboardCommand)A command is undone
DashboardCommandRedonecommand (DashboardCommand)A command is redone
DashboardBatchStartedreason (String)Batch operation begins
DashboardBatchEnded(none)Batch operation ends

DashboardExtension

abstract

Class Signature

Abstract interface for engine extensions.

Built-in Extensions

DashboardHistoryExtension

Class Signature

Properties

PropertyTypeDefaultDescription
extensionIdString (static)'dashboard-history'Unique extension identifier
canUndobool--Whether undo is available (reactive)
canRedobool--Whether redo is available (reactive)

Methods

  • undo
    Future<void> undo()

    Undoes the last command.

  • redo
    Future<void> redo()

    Redoes the last undone command.

  • clear
    void clear()

    Clears the history stack.


DashboardPersistenceExtension

Class Signature

Properties

PropertyTypeDefaultDescription
extensionIdString (static)'dashboard-persistence'Unique extension identifier
isDirtyObservable<bool>--Whether layout has unsaved changes

Methods

  • markClean
    void markClean()

    Resets the dirty flag.

  • markDirty
    void markDirty()

    Sets the dirty flag.

  • toJson returns Map<String, dynamic>
    Map<String, dynamic> toJson()

    Serializes the current layout.

  • fromJson
    void fromJson(Map<String, dynamic> json)

    Deserializes JSON with the registry and replaces the layout.

  • loadLayout
    void loadLayout(DashboardLayout layout)

    Replaces the layout directly.

Constructor requires the scoped DashboardEditorRegistry so JSON imports can recreate each component's PropertyCollection.


DashboardSelectionExtension

Class Signature

Properties

PropertyTypeDefaultDescription
extensionIdString (static)'dashboard-selection'Unique extension identifier
selectedCellRowIdObservable<String?>--Selected row ID
selectedCellColumnIdObservable<String?>--Selected column ID
showConfigPanelObservable<bool>--Whether config panel is visible
rightPanelModeObservable<DashboardRightPanelMode>--Panel mode
hoveredRowIdObservable<String?>--Hovered row
selectedCellComponentComponentInstance?--Component in selected cell
selectedRowDashboardRow?--Selected row
selectedColumnDashboardColumn?--Selected column
selectedCellHasComponentbool--Whether selected cell has a component

Selection methods: selectCell, selectCellOnly, selectCellWithComponent, selectRow, selectDashboard, selectComponent, clearSelection, openConfigPanel, closeConfigPanel.


DashboardAnalyticsExtension

Class Signature

Properties

PropertyTypeDefaultDescription
extensionIdString (static)'dashboard-analytics'Unique extension identifier

Tracks AddComponentCommand executions with a lightweight debug hook. Replace or augment it with an app-specific extension when you need production telemetry.


DashboardEditorController

Class Signature

Constructor Parameters

ParameterTypeRequiredDescription
initialLayoutDashboardLayout?NoOptional starting layout
registryDashboardEditorRegistryYesScoped registry used by the engine, persistence, palette, editor, and runtime view

Properties

PropertyTypeDefaultDescription
engineDashboardEngine--The underlying engine
historyDashboardHistoryExtension--History extension
persistenceDashboardPersistenceExtension--Persistence extension
selectionDashboardSelectionExtension--Selection extension
analyticsDashboardAnalyticsExtension--Analytics extension
layoutObservable<DashboardLayout>--Reactive layout
isDirtyObservable<bool>--Dirty flag
editingComponentIdObservable<String?>--Component being edited
editingPropertiesObservable<PropertyCollection?>--Draft properties for config panel
canUndobool--History can undo (computed)
canRedobool--History can redo (computed)
isEmptybool--No rows (computed)
canAddRowbool--Under max rows (computed)
rowCountint--Number of rows (computed)
componentCountint--Total components (computed)
selectedComponentComponentInstance?--Currently selected component (computed)
selectedRowDashboardRow?--Currently selected row (computed)
selectedColumnDashboardColumn?--Currently selected column (computed)

Methods

  • loadLayout
    void loadLayout(DashboardLayout newLayout)

    Clears history/selection, replaces the layout, and marks it clean.

  • markDirty
    void markDirty()

    Marks the layout as having unsaved changes.

  • markClean
    void markClean()

    Clears the dirty flag.

  • validate
    List<String> validate()

    Returns validation errors for the current layout.

  • toJson returns Map<String, dynamic>
    Map<String, dynamic> toJson()

    Serializes the current layout.

  • fromJson
    void fromJson(Map<String, dynamic> json)

    Clears history/selection and loads layout JSON via the persistence extension.

  • undo
    Future<void> undo()

    Delegates to the history extension.

  • redo
    Future<void> redo()

    Delegates to the history extension.

  • dispose
    void dispose()

    Disposes the selection-to-editing reaction, canvas focus node, scroll controller, JSON panel, and engine.

Facade composing the engine with all four extensions. The controller delegates all layout mutations, selection operations, undo/redo, and persistence to the respective engine methods and extensions.

Next Steps