invoke<T> method

T? invoke<T>([
  1. dynamic key = ''
])

Invokes an action by the given key, returns null if not found.

Note that if found action's type does not match given T, it will throw _CastError.

Implementation

T? invoke<T>([dynamic key = '']) {
  var r = _actions[key]?.call();
  if (r != null) {
    return r as T;
  }
  return null;
}