ComputedProperty class

Represents a computed property that derives its value from other state according to MCP UI DSL v1.0 specification.

Once ManagedComputedProperty from computed_manager.dart (which delegates expression evaluation to BindingEngine) supports all the features below, this class should be replaced. Until then it remains the active implementation used by StateManager.

Features not yet available in ManagedComputedProperty:

  • Ternary operator evaluation (condition ? trueValue : falseValue)
  • Logical operator evaluation (&&, ||)
  • Comparison operators (>, <, >=, <=, ==, !=)
  • Arithmetic operators (+, -, *, /, %)
  • Pipe/transform operations (| uppercase, | round, etc.)
  • Function calls (length(), sum())
  • Array access with index expressions
  • Circular dependency detection

Constructors

ComputedProperty({required String name, required String expression, required dynamic compute(Map<String, dynamic> state), List<String> dependencies = const [], bool enableDebugMode = kDebugMode})

Properties

cachedValue → dynamic
Gets the cached value if available
no setter
compute → dynamic Function(Map<String, dynamic> state)
Function that computes the property value from state
final
dependencies List<String>
List of state paths this property depends on
final
enableDebugMode bool
Whether debug mode is enabled
final
expression String
The expression string used to compute this property
final
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Gets whether this property has been computed
no setter
name String
The name/path of this computed property
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

computeAndCache(Map<String, dynamic> state) → dynamic
Computes and caches the property value
invalidate() → void
Invalidates the cached value
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRecompute(Map<String, String> changedPaths) bool
Checks if any of the dependencies have changed
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromExpression(String name, String expression, {List<String>? dependencies}) ComputedProperty
Creates a computed property from an expression string