I was wondering which is the best way to extend the CustomEvent
class, a class which has only one factory constructor. I tried doing the following and ran into an issue with the super constructor :
class MyExtendedEvent extends CustomEvent {
int count;
factory MyExtendedEvent(num count) {
return new MyExtendedEvent._internal(1);
}
MyExtendedEvent._internal(num count) {
this.count = count;
}
}
but I can't get it working. I always run into :
unresolved implicit call to super constructor 'CustomEvent()'
If i try chaning the internal constructor to :
MyExtendedEvent._internal(num count) : super('MyCustomEvent') {
this.count = count;
}
I end up with :
'resolved implicit call to super constructor 'CustomEvent()''.
I'm not sure what I'm doing wrong - but I guess the problem is that the CustomEvent
has only one constructor which is a factory constructor (as doc says - http://api.dartlang.org/docs/releases/latest/dart_html/CustomEvent.html)
What is the best way to extend a CustomEvent
, or any class of this form?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…