dynamic noSuchMethod(Invocation invocation)

Invoked when a non-existent method or property is accessed.

Classes can override noSuchMethod to provide custom behavior.

If a value is returned, it becomes the result of the original invocation.

The default behavior is to throw a NoSuchMethodError.

Source

noSuchMethod(Invocation invocation) {
  if (invocation.memberName != null) {
    String name = MirrorSystem.getName(invocation.memberName);
    if (properties.containsKey(name)) {
      if (invocation.isGetter)
        return properties[name];
      else if (invocation.isMethod) {
        return Function.apply(
            properties[name], invocation.positionalArguments,
            invocation.namedArguments);
      }
    }
  }

  super.noSuchMethod(invocation);
}