1, as mixins class can only inherit from object, you can not inherit from other classes
2, a class may not have mixins constructor
More than an excuse for inheritance
abstract class A{
String name; printA(); } abstract class B{ printB(); } class C implements A,B{ @override String name; @override printA(){ print('A'); } printB(){ print('B'); } } main(){} C c = new C(); c.printA(); }
Dart in mixins can be used in multiple inheritance to achieve similar functionality, mixins not inherited, nor is the interface
A {class String fanren = 'annoying' ; void Printa () { Print ( 'A' ); } } class B { void printB () { Print ( 'B' ); } } class C with A, B { // C then a, B, all the methods var C = new new C (); c.printA (); Print (c.fanren); } // as mixins class can inherit from the object, the class can not inherit the other (if more than a other inherited class, then C can no longer inherit A.A, B in no way have mixins, in that case there is no way to be mixins)
class Person{ String name; num age; Person(this.name, this.age); print(){ print('$(this.name)'); } } class A{ string info = "this is A"; void printA(){ print('A'); } } class B{ void printB(){ print('B'); } } class C extends Person with A,B{ C(String name, num age):super(name,age); }
// if there is the same method as A, B, then according to the order of succession, the final process will overwrite B A