Created
October 2, 2022 23:39
-
-
Save rhmndnt/8552747336bd7bf84555cabebc87e6d9 to your computer and use it in GitHub Desktop.
Dart Mixins Example
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 Swimmer { | |
void swim() { | |
print("swim"); | |
} | |
} | |
mixin Walker { | |
void walk() { | |
print("walk"); | |
} | |
} | |
mixin Fyler { | |
void swim() { | |
print("fyler"); | |
} | |
} | |
class Salmon with Swimmer {} | |
class Duck with Swimmer, Walker {} | |
void main() { | |
final salmon = Salmon(); | |
salmon.swim(); | |
final duck = Duck(); | |
duck.swim(); | |
duck.walk(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment