Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to group mixins in Dart?

Tags:

mixins

dart

I have a base package that defines A:

class A {}

Then a package that defines this:

mixin Aa on A {}
mixin Ab on A {}
abstract class First extends A with Aa, Ab{}

and another that defines this:

mixin Ax on A {}
mixin Ay on A {}
abstract class Last extends A with Ax, Ay {}

Then the package that gets that together with the problem

abstract class Clazz extends A with First, Last {} // <- Can't have those mixins bc they don't extend from Object

Question: Is there a way of grouping mixins or are we forced to implement them one by one?

like image 585
Nico Rodsevich Avatar asked Dec 06 '25 03:12

Nico Rodsevich


1 Answers

You are forced to implement the one-by-one.

There is currently no way to combine mixins into units that can be applied as one. Hopefully there will eventually be something like that. It's one the language team's radar (https://github.com/dart-lang/language/issues/540), but so is a lot of other enhancements.

like image 113
lrn Avatar answered Dec 08 '25 00:12

lrn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!