我来自Delphi,范例可能有所不同,但我想在Dart中定义一个自定义事件处理程序,类似于下面的伪代码。
// -- I don't know how to define this type...
typedeft TCustomEvent = function (int pParam) of object;
class MyFirstClass {
TCustomEvent onDoSomething;
void doIt(int pValue){
onDoSomething(pValue);
}
}
class MySecondClass {
void makeMyFirstClassDoIt(){
MyFirstClass vObj = MyFirstClass();
vObj.onDoSomething = doSomething;
vObj.doIt(5);
}
doSomething(int pValue) {
print(pValue);
}
}
任何帮助将不胜感激。