How to use dart to implement a delegate/proxy?
问题 I have two classes Parser and Proxy , and when I invoke a method from Parser , which does not exist, it will delegate it to Proxy class. My code: class Parser { noSuchMethod(Invocation invocation) { // how to pass the `invocation` to `Proxy`??? } } class Proxy { static String hello() { return "hello"; } static String world() { return "world"; } } That when I write: var parser = new Parser(); print(parser.hello()); It will print: hello 回答1: You have to use dart:mirrors . Here's how to do :