mixin Musical {
bool canPlayPiano = false;
bool canCompose = false;
bool canConduct = false;
void entertainMe() {
if (canPlayPiano) {
print('Playing piano');
} else if (canConduct) {
print('Waving hands');
} else {
print('Humming to self');
}
}
}
mixin Musical {
bool canPlayPiano = false;
bool canCompose = false;
bool canConduct = false;
void entertainMe() {
if (canPlayPiano) {
print('Playing piano');
} else if (canConduct) {
print('Waving hands');
} else {
print('Humming to self');
}
}
}
class Musician {
}
mixin MusicalPerformer on Musician {
String get title {
return "musician";
}
void playMusic() {
print("play music");
}
}
class SingerDancer extends Musician with MusicalPerformer {
// ...
}
// Error: 'Object' doesn't implement 'Musician' so it can't be used with 'MusicalPerformer'.
class Dancer with MusicalPerformer {
}
void main() {
var sd = SingerDancer();
sd.playMusic(); // OK
print(sd.title); // musician
var dancer = Dancer();
dancer.playMusic(); // Error
}