Skip to content

Properties

Properties give paths direct member access — ${tags.length} reads a list's length the same way it would in Dart, no function call required. When a path segment isn't a Map key or a List index, it resolves against the built-in properties for the value's type. Properties work anywhere paths work: EL expressions and Dart getValue calls alike.

<Text data="${tags.length}"/>

<Text data="${cart.isEmpty ? 'Your cart is empty' : 'Checkout'}"/>

<fragment name="alerts" visible="${alerts.isNotEmpty}"/>
final count = dependencies.getValue("tags.length");

Built-in Properties

Type Properties
String length, isEmpty, isNotEmpty
List / Set length, isEmpty, isNotEmpty, first, last
Map length, isEmpty, isNotEmpty, keys, values, entries
num isNegative, isNaN, isFinite, isInfinite, sign
int isEven, isOdd, plus the num properties
Duration inDays, inHours, inMinutes, inSeconds, inMilliseconds, isNegative
DateTime year, month, day, hour, minute, second, weekday, isUtc, millisecondsSinceEpoch

Resolution Rules

  • A real key always wins. On a Map, a property resolves only when the segment isn't an existing key: ${stats.length} reads the entry named length if the map has one, and the entry count otherwise.
  • Null chains stay null. ${user.tags.length} reads as null when user or tags is null — the same quiet degradation as any other path, so ?? supplies fallbacks.
  • Empty collections answer normally. ${tags.length} is 0 for an empty list and ${tags.isEmpty} is true.
  • first and last follow Dart. On an empty collection they throw a StateError, exactly as in Dart — guard with isNotEmpty when the collection may be empty.
  • Unknown names read as null on a Map (indistinguishable from a missing key) and throw on other types, so typos fail loudly instead of rendering blanks.

Properties vs Instance Functions

Some members are available both ways: ${name.length} and ${name.length()} return the same value. Prefer the property form for value-like members; the instance function forms remain for chaining and for members that take arguments.

Custom Types

Register a property resolver to give your own types properties — see Property Resolvers.