execute method

dynamic execute(
  1. String? key,
  2. Iterable? args
)

Executes the dynamic function named key. This will first check for a custom dynamic function using the key, and if none is found, this will then check the internal functions. If no function can be found in either collection, this will throw an Exception.

Implementation

dynamic execute(
  String? key,
  Iterable<dynamic>? args,
) {
  final fun = _functions[key!];
  if (fun == null) {
    if (_parent == null) {
      throw Exception(
        'No function named "$key" found in the registry [$debugLabel].',
      );
    } else {
      return _parent!.execute(key, args);
    }
  }

  return fun(
    args: args as List<dynamic>?,
    registry: this,
  );
}