I'm new to Dart, and I wonder if, for example, I can extend the DivElement class to create custom elements in one line of code. I am looking for something like this;
class RedBox extends DivElement {
RedBox(text) {
this.text = text;
this.style.background = "red";
}
}
RedBox myBox = new RedBox("Hello World");
document.body.append(myBox);
Of course, I will have much more complex elements with custom functions. But as a rule, is this possible?
When I try to run this, I get:
implicit call to super constructor 'DivElement()'
source
share