79108178

Date: 2024-10-20 22:35:52
Score: 0.5
Natty:
Report link
/*normal class u can create constructors create objects from it 
 and all that good jazz*/

class Foo {
  final int a;
  Foo(this.a);
  void someMethod() {}
}
/*mixin is like a container than hold some 
  functionalities that you want to mix with an existing class*/

mixin Bar {
  void add() {}
}

/* this class extends Foo to inherent some goodness but i need a 
 functionality that is not directly related to parent child 
 relationship so i mix it with Bar */

class Baz extends Foo with Bar {
  Baz(super.a);

  void myMethod() {
    // i have access to add function here
    add();
  }
}

// mixin class act like both
mixin class AnotherClass {
  AnotherClass();
}
Reasons:
  • Blacklisted phrase (0.5): i need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: anass Sanba