I was wondering what is the best way to extend the CustomEvent class, a class that has only one factory constructor. I tried to do the following and ran into a problem 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 to work. I always come across:
unresolved implicit call to the 'CustomEvent ()' super constructor
If I try to make an internal constructor for:
MyExtendedEvent._internal(num count) : super('MyCustomEvent') { this.count = count; }
In the end, I:
'allowed to implicitly call the superstructor' CustomEvent () ''.
I'm not sure what I'm doing wrong - but I think the problem is that CustomEvent has only one constructor, which is the factory constructor (as doc says - http://api.dartlang.org/docs/releases/latest/dart_html /CustomEvent.html )
What is the best way to extend CustomEvent or any class of this form?
source share