← Map
Dart Island · Level 9
Learn Flutter

Mixins

Mixins let you reuse behaviour across classes without inheritance. Instead of extending one parent, you mix in multiple capabilities using the with keyword.
10 games: drag abilities onto animals, resolve conflicts, design your own mixins.
What is a mixin?

A mixin is a bundle of methods you can mix into any class using with. The class gains those methods without inheriting from a parent.

mixin Flyable {
void fly() => print('I can fly!');
}
mixin Swimmable {
void swim() => print('I can swim!');
}
class Duck with Flyable, Swimmable {
// Duck can now fly() AND swim()
}
  • mixin — defines a reusable capability (not a full class)
  • with — mix in one or more mixins to a class
  • on — constrain a mixin to only work on specific classes
  • Order — rightmost mixin wins on method conflicts
Progress
0 / 10 mini-games solved
Stage 1

Mixin Mix

Drag capability badges onto animal cards.

1. Click a capability badge below.
2. Click the animal that should have that ability.

Island map