Skip to content

Layout API

Reference documentation for the layout model classes: DashboardLayout, DashboardRow, DashboardColumn, ComponentInstance, and DashboardLayoutConstants.

DashboardLayout

Class Signature

Properties

PropertyTypeDefaultDescription
versionString'2.0.0'Schema version
rowsList<DashboardRow>--Ordered list of rows
metadataMap<String, dynamic>?nullOptional metadata (name, apiBaseUrl, etc.)
canAddRowbool--rows.length < maxRows
rowCountint--Number of rows
isEmptybool--Whether there are no rows
componentCountint--Total filled columns across all rows
totalColumnsint--Total columns across all rows
emptySlotCountint--Total empty columns
apiBaseUrlString?--API base URL from metadata
maxRowsint (static)25Maximum number of rows allowed

Methods

  • DashboardLayout.empty
    factory DashboardLayout.empty()

    Creates an empty layout with no rows.

  • DashboardLayout.withRows
    factory DashboardLayout.withRows(List<DashboardRow> rows)

    Creates a layout from rows, sorted by their order field.

  • copyWith
    DashboardLayout copyWith({
      String? version,
      List<DashboardRow>? rows,
      Map<String, dynamic>? metadata,
      bool clearMetadata = false,
    })

    Returns a copy with updated fields.

  • withApiBaseUrl
    DashboardLayout withApiBaseUrl(String baseUrl)

    Returns a copy with the apiBaseUrl set in metadata.

  • fromJson
    factory DashboardLayout.fromJson(Map<String, dynamic> json, {required DashboardEditorRegistry registry})

    Deserializes a layout from JSON and uses the registry to recreate component property collections.

  • toJson
    Map<String, dynamic> toJson()

    Serializes the layout to JSON.

Top-level container for the entire dashboard.


DashboardRow

Class Signature

Properties

PropertyTypeDefaultDescription
idString--Unique row identifier
columnsList<DashboardColumn>--1-6 columns
orderint--Display order (0-based)
titleString?nullOptional display title
heightdouble?nullFixed height in pixels (null = use default 60)
viewportFractiondouble?nullViewport-relative height (0.1+). Overrides height.
metadataMap<String, dynamic>?nullOptional metadata
maxColumnsint (static)6Maximum columns per row
usesViewportFractionbool--viewportFraction != null
effectiveHeightdouble--height ?? 60.0
canAddColumnbool--columns.length < 6
hasEmptyColumnsbool--Any column has no component
isCompletelyEmptybool--All columns are empty
isCompletelyFilledbool--All columns have components
columnCountint--Number of columns
totalFlexint--Sum of all column flex values
emptyColumnsList<DashboardColumn>--Columns without components
filledColumnsList<DashboardColumn>--Columns with components

Methods

  • DashboardRow.single
    factory DashboardRow.single(String id, int order, String columnId)

    Creates a row with one column at full flex (6).

  • DashboardRow.withColumns
    factory DashboardRow.withColumns(String id, int order, List<String> columnIds)

    Creates a row with evenly distributed flex.

  • distributeFlex
    static List<int> distributeFlex(int count)

    Distributes 6 flex units evenly across count columns. Remainder goes to leading columns.

  • normalizedFlex
    DashboardRow normalizedFlex()

    Returns a copy where column flex values are adjusted to sum to 6.

  • copyWith
    DashboardRow copyWith({
      String? id,
      List<DashboardColumn>? columns,
      int? order,
      String? title,
      double? height,
      double? viewportFraction,
      Map<String, dynamic>? metadata,
      bool clearTitle = false,
      bool clearHeight = false,
      bool clearViewportFraction = false,
      bool clearMetadata = false,
    })

    Returns a copy with updated fields.

  • fromJson
    factory DashboardRow.fromJson(Map<String, dynamic> json, {required DashboardEditorRegistry registry})

    Deserializes a row from JSON and passes the registry to columns/components.

  • toJson
    Map<String, dynamic> toJson()

    Serializes the row to JSON.

A horizontal container for 1-6 columns.


DashboardColumn

Class Signature

Properties

PropertyTypeDefaultDescription
idString--Unique column identifier
flexint1Flex factor (1-6)
componentComponentInstance?nullComponent (null if empty)
isEmptybool--component == null
hasComponentbool--component != null

Methods

  • DashboardColumn.empty
    factory DashboardColumn.empty(String id, {int flex = 1})

    Creates an empty column.

  • DashboardColumn.withComponent
    factory DashboardColumn.withComponent(String id, ComponentInstance component, {int flex = 1})

    Creates a column pre-populated with a component.

  • copyWith
    DashboardColumn copyWith({
      String? id,
      int? flex,
      ComponentInstance? component,
      bool clearComponent = false,
    })

    Returns a copy with updated fields.

  • fromJson
    factory DashboardColumn.fromJson(Map<String, dynamic> json, {required DashboardEditorRegistry registry})

    Deserializes a column from JSON and passes the registry to the component instance.

  • toJson
    Map<String, dynamic> toJson()

    Serializes the column to JSON.

A vertical slot within a row that holds zero or one component.


ComponentInstance

Class Signature

Properties

PropertyTypeDefaultDescription
idString--Unique component identifier
componentKeyString--References registered component
titleString?nullOptional display title
propertiesPropertyCollection--Type-safe component configuration
metadataMap<String, dynamic>?nullOptional metadata

Methods

  • ComponentInstance.withDefaults
    factory ComponentInstance.withDefaults({
      required String id,
      required String componentKey,
      String? title,
      required DashboardEditorRegistry registry,
      Map<String, dynamic>? configOverrides,
    })

    Looks up the component in DashboardEditorRegistry, calls createProperties(), and applies overrides via fromJson.

  • copyWith
    ComponentInstance copyWith({
      String? id,
      String? componentKey,
      String? title,
      PropertyCollection? properties,
      Map<String, dynamic>? metadata,
      bool clearTitle = false,
      bool clearMetadata = false,
    })

    Returns a copy with updated fields.

  • fromJson
    factory ComponentInstance.fromJson(Map<String, dynamic> json, {required DashboardEditorRegistry registry})

    Deserializes a component instance and uses the registry to create the correct PropertyCollection.

  • toJson
    Map<String, dynamic> toJson()

    Serializes the component instance to JSON.

A component instance placed inside a column.


DashboardLayoutConstants

Class Signature

Properties

PropertyTypeDefaultDescription
cellGapdouble16.0Gap between rows and columns
minCellHeightdouble60.0Default minimum row height
maxCellHeightdouble800.0Maximum row height
fillRowEditorPreviewHeightdouble200.0Preview height for viewport-fraction rows in editor
toolbarHeightdouble48.0Editor toolbar height
resizeHandleHeightdouble8.0Row resize handle height
editorInsetdouble12.0Inset padding around components in editor mode
totalFlexPerRowint6Total flex units per row
minColumnFlexint1Minimum flex per column

Centralized constants for the dashboard editor.

Next Steps