27. mixin & with
Mixins are a way of reusing a class’s code in multiple class hierarchies.
簡單來說就是:
我提供⼀些⽅法給你使⽤,但我不⽤成為你的⽗類別。
mixin ShowName {
void showName() {
print('mixin ShowName');
}
}
class Quadrilateral with ShowName {
void showAllSideLength() {
showName();
}
}
https://ithelp.ithome.com.tw/articles/10268368?sc=iThelpR