How can I make the constructor of B use the same default text as the constructor A without specifying it again?
Created
November 5, 2020 22:48
-
-
Save fischerscode/70a2895cfc0ad6334ba30e91e7e92c89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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