Skip to content

Instantly share code, notes, and snippets.

@shivanchalaeologic
Created July 2, 2020 14:16
Show Gist options
  • Save shivanchalaeologic/7d46d908d727dd6f3f3d774565666973 to your computer and use it in GitHub Desktop.
Save shivanchalaeologic/7d46d908d727dd6f3f3d774565666973 to your computer and use it in GitHub Desktop.
mixin Swim {
void swim() => print('Swimming');
}
mixin Bite {
void bite() => print('Chomp');
}
mixin Crawl {
void crawl() => print('Crawling');
}
abstract class Reptile with Swim, Crawl, Bite {
void hunt(food) {
print('${this.runtimeType} -------');
swim();
crawl();
bite();
print('Eat $food');
}
}
class Alligator extends Reptile {
// Alligator Specific stuff...
}
class Crocodile extends Reptile {
// Crocodile Specific stuff...
}
class Fish with Swim, Bite {
void feed() {
print('Fish --------');
swim();
bite();
}
}
main() {
Crocodile().hunt('Deer');
Alligator().hunt('Fish');
Fish().feed();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment