I've the below custom element, and I want to register it in the same file
custombtn.dart:
class SubmitFonix extends HtmlElement {
String name;
factory SubmitFonix([String name]) => (new Element.tag(tag) as SubmitFonix)
..name=name
;
SubmitFonix.created() : super.created() {
...
}
currently, I'm registering the element in the main function, as this:
void main() {
document.registerElement(SubmitFonix.tag, SubmitFonix);
}
I wanted to add the registration line to the custombtn.dart file, instead of having it in the main() function, but if I could not!
in polymer.dart, I noticed they are using below statement:
@initMethod
upgradePaperFocusable() => registerDartType('paper-focusable', PaperFocusable);
and in other file they have:
const initMethod = const InitMethodAnnotation();
class InitMethodAnnotation {
const InitMethodAnnotation();
}
so, tried using the same concept, and updated my custom element file to be as:
class SubmitFonix extends HtmlElement {
String name;
factory SubmitFonix([String name]) => (new Element.tag(tag) as SubmitFonix)
..name=name
;
SubmitFonix.created() : super.created() {
...
}
@initMethod
upgradeCustomBtn() => document.registerElement(SubmitFonix.tag, SubmitFonix);
at execution, I got this this error in the console:
Exception: type 'HtmlElement' is not a subtype of type 'SubmitFonix' in type cast.
submit_btn.dart:10
SubmitFonix.SubmitFonix.
submit_btn.dart:10 is: factory SubmitFonix([String name]) => (new Element.tag(tag) as SubmitFonix)
any thought?