Dart : Mixing Class

Dart : Mixing Class

·

1 min read

Mixing Class

  • A mixin is a class with methods and properties utilized by other classes in Dart.

  • It is a way to reuse code and write code clean.

  • To declare a mixin, we use the mixin keyword:

  •   mixin Mixin_name{
       }
    
mixin Fly {

    void fly() {
        print('Flying...');    
    }
}

class Bird with Fly {

}

void main()
{
    var bird = Bird();
    bird.fly();

}
Flying...

Exited.