- @override
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
@override
dynamic noSuchMethod(Invocation invocation) {
if (invocation.isGetter) {
var propertyName = MirrorSystem.getName(invocation.memberName);
return this[propertyName];
} else if (invocation.isSetter) {
var propertyName = MirrorSystem.getName(invocation.memberName);
if (propertyName.endsWith("=")) {
propertyName = propertyName.substring(0, propertyName.length - 1);
}
this[propertyName] = invocation.positionalArguments.first;
return null;
}
return super.noSuchMethod(invocation);
}