Mixins
A mixin shares behaviour across classes without inheritance. Apply with with.
Example
mixin Swims { String swim() => "swimming"; }
mixin Flies { String fly() => "flying"; }
class Duck with Swims, Flies {}
void main() {
var d = Duck();
print("${d.swim()} and ${d.fly()}");
}Exercise
Use a mixin.
class A M
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.