When to use mixins and when to use interfaces in Dart?

后端 未结 6 1956
眼角桃花
眼角桃花 2020-12-07 19:28

I\'m very familiar with the concepts of interfaces and abstract classes, but not super familiar with the concepts of mixins.

Right now, in Dart, every clas

6条回答
  •  粉色の甜心
    2020-12-07 19:33

    mixin is same as protocols in swift. in swift you can define protocols with default implementation. mixin also provide this capability.

    if you want to provide default implementation for protocols while conforming to these protocols or want to conform multiple protocols use mixin. otherwise use interface.

提交回复
热议问题