Instance Functions
Overview
Instance functions operate directly on values and expressions within EL (Expression Language), enabling method-style chaining and manipulation. Unlike static functions that are called globally, instance functions are invoked on specific objects using dot notation. This approach provides object-oriented access to common operations like string manipulation, collection queries, and numeric transformations.
Argument-less members are also available without parentheses as
properties — ${name.length} and ${name.length()} return the
same value.
Important
Not all Dart instance methods are supported. Calling an unsupported function
throws Exception: Function '<name>' not found. The functions listed below are
the built-in instance methods; functions stored as Map values are also
callable as methods on that map.
Numeric Functions
abs
Returns the absolute value of a number.
ceil
Rounds a number up to the nearest integer.
floor
Rounds a number down to the nearest integer.
round
Rounds a number to the nearest integer.
truncate
Truncates a number to an integer by removing the fractional part.
toDouble
Converts a number to a double.
toInt
Converts a number to an integer.
toRadixString
Converts a number to a string representation in the specified radix (base).
isEven
Checks if a number is even.
isOdd
Checks if a number is odd.
isFinite
Checks if a number is finite.
isInfinite
Checks if a number is infinite.
isNaN
Checks if a number is Not-a-Number (NaN).
isNegative
Checks if a number is negative.
compareTo
Compares this number to another, returning -1, 0, or 1.
String Functions
length
Returns the length of a string.
isEmpty
Checks if a string is empty.
isNotEmpty
Checks if a string is not empty.
toLowerCase
Converts a string to lowercase.
toUpperCase
Converts a string to uppercase.
trim
Removes leading and trailing whitespace.
trimLeft
Removes leading whitespace.
trimRight
Removes trailing whitespace.
startsWith
Checks if a string starts with the specified substring.
endsWith
Checks if a string ends with the specified substring.
contains
Checks if a string contains the specified substring.
indexOf
Returns the index of the first occurrence of a substring.
lastIndexOf
Returns the index of the last occurrence of a substring.
substring
Extracts a substring from start to end index.
split
Splits a string into a list using the specified pattern.
replaceAll
Replaces all occurrences of a pattern with a replacement string.
replaceFirst
Replaces the first occurrence of a pattern with a replacement string.
replaceRange
Replaces the substring from start to end with a replacement string.
padLeft
Pads a string on the left to reach the specified width.
padRight
Pads a string on the right to reach the specified width.
toString
Converts a value to its string representation.
Collection Functions
length
Returns the number of elements in a collection.
isEmpty
Checks if a collection is empty.
isNotEmpty
Checks if a collection is not empty.
first
Returns the first element in a collection.
last
Returns the last element in a collection.
single
Returns the single element in a collection (throws if not exactly one element).
elementAt
Returns the element at the specified index.
contains
Checks if a collection contains the specified element.
indexOf
Returns the index of the first occurrence of an element.
lastIndexOf
Returns the index of the last occurrence of an element.
sublist
Returns a sublist from start to end index.
toList
Converts a collection to a list.
toSet
Converts a collection to a set.
shuffle
Randomly shuffles the elements in a list.
<!-- expressions evaluate at inflation time; use <callback> to defer to the tap -->
<Button>
<callback for="onPressed" action="items.shuffle()"/>
<Text data="Shuffle"/>
</Button>
Map Functions
containsKey
Checks if a map contains the specified key.
containsValue
Checks if a map contains the specified value.
keys
Returns an iterable of all keys in the map.
values
Returns an iterable of all values in the map.
entries
Returns an iterable of all key-value pairs in the map.
isEmpty
Checks if a map is empty.
isNotEmpty
Checks if a map is not empty.
length
Returns the number of key-value pairs in the map.
Set Functions
difference
Returns a set containing elements in this set but not in the other set.
intersection
Returns a set containing elements present in both sets.
union
Returns a set containing all elements from both sets.
Object Functions
runtimeType
Returns the runtime type of an object.
toString
Returns a string representation of an object.