Mixin is an incomplete class that can be mixed into multiple classes. For example,
mixin Fluttering { void flutter() { print('fluttering'); } } abstract class Bird with Fluttering { void chirp() { print('chirp chirp'); } }
Note that the Fluttering mixin can be used in multiple classes. If we want to restrict the mixin to be used only in a particular class, we can use the “on” keyword. For example,
mixin Pecking on Bird { void peck() { print('pecking'); chirp(); } } class Sparrow extends Bird with Pecking {} class BlueJay extends Bird with Pecking {}
This is useful above as mixin Pecking can call chirp() method which is defined in Bird. Without specifying with “on”, Dart does not know where to look for the method chirp.
See also https://resocoder.com/2019/07/21/mixins-in-dart-understand-dart-flutter-fundamentals-tutorial/