callMethod method

  1. @override
dynamic callMethod(
  1. String methodName,
  2. List args
)
override

Implementation

@override
callMethod(String methodName, List<dynamic> args) {
  Map<String, Function> _methods = methods();
  if (methodName == 'max' || methodName == 'min' || methodName == 'sqrt') {
    // Special handling for max and min to support multiple arguments.
    return _methods[methodName]!(args);
  } else if (_methods.containsKey(methodName)) {
    if (args.length > 0) {
      return Function.apply(_methods[methodName]!, args);
    } else {
      if (methodName == 'random') {
        return Function.apply(_methods[methodName]!, null);
      }
      return Function.apply(_methods[methodName]!, [null]);
    }
  } else {
    throw 'Method not found';
  }
}