Skip to content

Custom Functions

Overview

Custom functions are user-defined functions that you can add to any Dependencies instance. While they behave similarly to static functions, they are bound to a single Dependencies instance.

It's important to note that custom functions can only accept positional arguments, which means they cannot use named parameters.

Example

// Define a custom function
void greet(String name) {
  return 'Hello, $name!';
}

// Add the custom function to your Dependencies instance
final dependencies = Dependencies();
dependencies.setValue("greet", greet);
<!--  Call 'greet' custom function -->
<Text data="${greet('Sally')}"/>