Created
April 6, 2024 19:11
-
-
Save roboli/56c887684026bb25fc3fd35761b0a94c to your computer and use it in GitHub Desktop.
Dart: Access Mixins and Class instance variables
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
mixin Address on Person { | |
late final String address; | |
say() { | |
print("Name: $name, Address: $address"); | |
} | |
} | |
class Person { | |
late final String name; | |
Person(this.name); | |
} | |
class Child extends Person with Address { | |
Child(super.name, address) { | |
this.address = address; | |
} | |
} | |
void main() { | |
final one = Child("Robs Oliver", "1st St. Wonderland"); | |
one.say(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment