Skip to content

Property System

Dynamic Property Configuration

A standalone, type-safe property system for dynamic object configuration in Flutter. Provides generic Property<T> wrappers, built-in editors for common types, validation, conditional visibility, JSON serialization, and reactive_forms integration -- no vyuh_core dependency required.

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, Enum, List, Union, and ReadOnly properties with optional-value variants.

Validation & Conditions

PropertyValidator<T> for validation rules. PropertyCondition for reactive visibility and enabled state based on other property values.

JSON Serialization

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

Getting Started

Core Concepts

Core Components

ComponentDescription
Property<T>Generic property wrapper with key, label, default value, validation, and conditions
PropertyControl<T>Typed control abstraction over reactive_forms FormControl, with value, validation, and enabled state
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
PropertyConditionConditional visibility/enabled state (equals, in, comparison, and/or, custom)
PropertyValidator<T>Validation rules with required, min, max, pattern, email, and custom validators
JsonConverter<T>Type-safe serialization/deserialization with type-to-converter registry

Learn More

Quick Example

Build a course settings panel using the fluent PropertyCollectionBuilder:

dart
import 'package:vyuh_property_system/vyuh_property_system.dart';

// Define course level options
enum CourseLevel { beginner, intermediate, advanced }

// Build the property collection
final builder = PropertyCollectionBuilder()
  ..group('basic', 'Basic Info')
  ..string('title', 'Course Title', required: true)
  ..string('description', 'Description')
  ..integer('duration', 'Duration (hours)', defaultValue: 1,
    validators: [PropertyValidators.min(1)])
  ..group('enrollment', 'Enrollment')
  ..enumeration<CourseLevel>('level', 'Course Level',
    options: [
      EnumOption(CourseLevel.beginner, 'Beginner'),
      EnumOption(CourseLevel.intermediate, 'Intermediate'),
      EnumOption(CourseLevel.advanced, 'Advanced'),
    ],
    defaultValue: CourseLevel.beginner)
  ..boolean('enrollmentOpen', 'Open Enrollment', defaultValue: true)
  ..integer('capacity', 'Max Capacity', defaultValue: 30,
    visibleCondition: PropertyCollectionBuilder.whenTrue('enrollmentOpen'));

final collection = builder.buildCollection();

// Render as an editable form
PropertyCollectionEditor(collection: collection);

// Read values and serialize
print(collection.getValue<String>('title'));
print(collection.toJson());

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 with reordering
UnionProperty(direct)Select one property from multiple options
ReadOnlyProperty<T>readonly()Display-only, non-editable value

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