Skip to content

Instantly share code, notes, and snippets.

@fischerscode
Created November 5, 2020 22:48
Show Gist options
  • Save fischerscode/70a2895cfc0ad6334ba30e91e7e92c89 to your computer and use it in GitHub Desktop.
Save fischerscode/70a2895cfc0ad6334ba30e91e7e92c89 to your computer and use it in GitHub Desktop.

How can I make the constructor of B use the same default text as the constructor A without specifying it again?

void main() async {
print(B().text);
}
class A{
A({this.text = "test text"});
final text;
}
class B extends A{
B({String text}) : super(text: text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment