Property System
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
| Component | Description |
|---|---|
| Property<T> | Generic property wrapper with key, label, default value, validation, and conditions |
| PropertyCollection | Groups properties with reactive_forms FormGroup, conditional visibility, and change tracking |
| PropertyCollectionBuilder | Fluent builder for constructing property groups and properties with less boilerplate |
| PropertyCollectionEditor | Flutter widget that renders a property collection as an editable form |
| PropertyValidator<T> | Validation rules for property values |
| PropertyCondition | Conditional visibility/enabled state (equals, in, comparison, custom) |
| JsonConverter<T> | Serialization/deserialization with type-to-converter registry |
Packages
Built-in Property Types
| Property | Builder Method | Description |
|---|---|---|
StringProperty | string() | Text value with string editor |
IntProperty | integer() | Integer value with number editor |
DoubleProperty | decimal() | Decimal value with number editor |
BoolProperty | boolean() | Boolean value with toggle editor |
DateTimeProperty | dateTime() | 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.
// 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}'),
);