-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Consider someone creating a Flutter package that extends a bunch of widgets with an extra argument, for example adding an isEnabled
argument to every button, which changes how the onPressed
argument gets forwarded.
Currently, if they do this, every time the superclass constructor is changed, they have to republish their package with an update. This leads to the likelihood that the package will eventually be abandoned and won't be updated (since that is work). It also means the package will only work with some versions (those that match the API the package expected).
Imagine if instead they could provide a constructor that is defined to have all the arguments of the superclass, with just a few "edits", as in:
class MySuperButton extends Button {
MySuperButton(...super, { bool isEnabled })
: super(
onPressed: isEnabled ? onPressed : null,
...super,
);
}
...where ...super
stands for "fill in everything from the superclass that isn't overridden here".
See also dart-lang/sdk#22274 which is similar but doesn't involve overriding. This proposal would make that one irrelevant (it just becomes MySuperButton(...super)
or some such).