Skip to content

Instantly share code, notes, and snippets.

@jaripekkala
Created April 14, 2020 11:58
Show Gist options
  • Save jaripekkala/dcdc41574fcab44c98d44eceded1846a to your computer and use it in GitHub Desktop.
Save jaripekkala/dcdc41574fcab44c98d44eceded1846a to your computer and use it in GitHub Desktop.
Mixins
void main() {
final dev = Developer();
dev.speak();
final mgr = Manager();
mgr.speak();
}
abstract class Person {
String get saying;
void speak();
}
mixin LoudSpeak implements Person {
void speak() {
print(saying.toUpperCase());
}
}
class Developer with LoudSpeak implements Person {
final String saying = 'foo';
}
class Manager with LoudSpeak implements Person {
final String saying = 'testi';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment