I would like to extend Text class which has following constructor:
const Text(this.data, {
Key key,
this.style,
this.textAlign,
this.softWrap,
this.overflow,
this.textScaleFactor,
this.maxLines,
}) : assert(data != null),
super(key: key);
But I have issues with super's optional parameters and syntax. So, what I am trying to do is something like:
BlinkingText(data,
{key,
style,
textAlign,
softWrap,
overflow,
textScaleFactor,
maxLines}):
super(data, {key, style, textAlign, softWrap, overflow, textScaleFactor, maxLines});
But syntax is wrong. So I wonder how should I deal with optional arguments and if there is a simple way to get a bunch of arguments and pass them as I get them to super.
There is no shorthand for passing all your arguments to the super-class.
You pass named arguments by prefixing them with the name, so:
BlinkingText(data,
{key,
style,
textAlign,
softWrap,
overflow,
textScaleFactor,
maxLines})
: super(data, key: key, style: style, textAlign: textAlign,
softWrap: softWrap, overflow:overflow,
textScaleFactor: textScaleFactor, maxLines: maxLines);
That's the same way you use named arguments with non-constructor functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With