Skip to content

Expression Language (EL)

XWidget EL is the expression language inside ${...}. Expressions read values from the fragment's Dependencies, combine them with operators and function calls, and hand the result to the attribute they appear in.

<!-- Full expression -->
<Text data="${user.name}"/>

<!-- Embedded in text -->
<Text data="Hello, ${user.name}!"/>

<!-- In conditional attributes -->
<fragment name="panel" visible="${isAdmin}"/>

References like user.name resolve against the fragment's Dependencies using the same dot/bracket paths as getValue — a missing path reads as null rather than throwing, so expressions degrade quietly and ?? supplies fallbacks:

<Text data="${user.nickname ?? user.name}"/>

Path segments that aren't keys or indexes resolve as properties${tags.length}, ${cart.isEmpty} — the way they would in Dart.

Expressions evaluate when the fragment is inflated. They don't re-evaluate on their own when data changes — wrap dependent UI in a <ValueListener> or <EventListener> to rebuild it. See State and Reactivity.

Literals

Literal Examples
Numbers 42, 3.14
Strings 'hello' — single quotes only
Booleans true, false
Null null

Important

Strings must be enclosed in single quotes ('). Double quotes (") are not supported.

Operator Precedence

Higher levels bind tighter: when two operators share an operand, the one with the higher level applies first, and ties are broken by associativity.

Level Operator Category Associativity
11 identifier
'string'
123
Primary Expressions (references, string literals, numbers) N/A
10 ()
[]
.
Function call, scope, array/member access Left-to-right
9 -expr
!expr
Unary Prefix (negation, NOT) Right-to-left
8 *
/
~/
%
Multiplicative Operators Left-to-right
7 +
-
Additive Operators Left-to-right
6 <
>
<=
>=
Relational Operators Left-to-right
5 ==
!=
Equality Operators Left-to-right
4 && Logical AND Left-to-right
3 || Logical OR Left-to-right
2 expr1 ?? expr2 Null Coalescing (If null) Left-to-right
1 expr ? expr1 : expr2 Conditional (ternary) Operator Right-to-left

Functions

Expressions can call three kinds of functions:

  • Static functions — built-ins available everywhere, like length(), formatDateTime(), and isEmpty().
  • Instance functions — method-style calls on values, like ${user.name.toUpperCase()}.
  • Custom functions — your own Dart functions, registered or bound through Dependencies.

Values also expose properties — members accessed directly, like ${tags.length} and ${cart.isEmpty}.