Skip to content

Property System

Dynamic Property Configuration

A type-safe property system for dynamic object configuration in Flutter. Provides generic Property<T> wrappers, built-in editors for common types, validation, JSON serialization, and integration with reactive_forms.

Key Capabilities

Type-Safe Properties

Generic Property<T> wrappers with metadata, validation, and JSON serialization. No stringly-typed configuration.

Built-in Property Editors

Pre-built editors for String, Int, Double, Bool, DateTime, and ReadOnly properties with optional-value variants.

Validation

PropertyValidator<T> for defining validation rules on individual properties. Validation integrates with reactive_forms.

JSON Serialization

JsonConverter<T> system with a type-to-converter registry for automatic serialization and deserialization.

Core Components

ComponentDescription
Property<T>Generic property wrapper with key, label, default value, validation, and conditions
PropertyCollectionGroups properties with reactive_forms FormGroup, conditional visibility, and change tracking
PropertyCollectionBuilderFluent builder for constructing property groups and properties with less boilerplate
PropertyCollectionEditorFlutter widget that renders a property collection as an editable form
PropertyValidator<T>Validation rules for property values
PropertyConditionConditional visibility/enabled state (equals, in, comparison, custom)
JsonConverter<T>Serialization/deserialization with type-to-converter registry

Packages

Built-in Property Types

PropertyBuilder MethodDescription
StringPropertystring()Text value with string editor
IntPropertyinteger()Integer value with number editor
DoublePropertydecimal()Decimal value with number editor
BoolPropertyboolean()Boolean value with toggle editor
DateTimePropertydateTime()Date/time value with picker editor
EnumProperty<T>enumeration()Enum selection from typed options
ListProperty<T>list()List of typed values
ReadOnlyProperty<T>readonly()Display-only, non-editable value

Each type also has an Optional variant (e.g., OptionalStringProperty / optionalText()) for nullable values.

Usage

The Property System is primarily used by the Dashboard Editor and Form Editor for configuring component properties at design time. It provides the underlying infrastructure for property panels where users edit component settings.

dart
// Build properties for a dashboard component using the fluent builder
final builder = PropertyCollectionBuilder()
  ..group('appearance', 'Appearance')
  ..string('title', 'Chart Title', defaultValue: 'Untitled', required: true)
  ..boolean('showLegend', 'Show Legend', defaultValue: true)
  ..group('data', 'Data Configuration')
  ..integer('refreshInterval', 'Refresh Interval (sec)', defaultValue: 30)
  ..string('dataSource', 'API Endpoint', help: 'REST endpoint for chart data');

final properties = builder.buildCollection();

// Or construct properties directly
final titleProp = StringProperty(
  key: 'title',
  label: 'Chart Title',
  defaultValue: 'Untitled',
  required: true,
);

// Render the property editor UI
PropertyCollectionEditor(
  collection: properties,
  onChanged: () => print('Properties updated: ${properties.values}'),
);