Dart pass this as a parameter in a constructor
问题 Lets say that I have an abstract class abstract class OnClickHandler { void doA(); void doB(); } I have a class class MyClass { OnClickHandler onClickHandler; MyClass({ this.onClickHandler }) void someFunction() { onClickHandler.doA(); } } And I have a class class Main implements onClickHandler { // This throws me an error MyClass _myClass = MyClass(onClickHandler = this); // <- Invalid reference to 'this' expression @override void doA() {} @override void doB() {} } How can I say that use the