Description
We would like to deprecate and eventually stop supporting using class
declarations as mixins. There are a couple of proposals out for how to do that: #1529 and #1643. The main sticking point for simply making it a warning or error to mix in a class is Flutter.
Flutter has a number of class declarations that are widely used as both mixins (in with
clauses) and as superclasses (in extends
clauses). Flutter can't change those class declarations to be explicit mixin
declarations because it would break every extends
use of the classes in the wild today.
We could potentially have a deprecation period where we encourage Flutter users to change all of those extends ___
to extends Object with ___
, but it's not clear that that's actually a desirable ecosystem change. Most Dart users seem to be unaware of mixins so forcing them to learn about with
before they can use common functionality like ChangeNotifier might be punishing for little benefit.
Here is a simpler proposal:
-
Allow using
extends ___
on mixins and treat it as syntactic sugar forextends Object with ___
. Unlike the previous proposals, we don't make this a temporary language feature. Instead, we simply allow that sugar henceforth and forever.With this, Flutter classes like
ChangeNotifier
can immediately be changed tomixin
instead ofclass
without breaking or effecting any users. -
After Flutter and other key packages have migrated their mixin-in-able classes to use
mixin
, add a linter rule that warns when users mixin a type declared usingclass
. Eventually promote that to a warning. -
In Dart 3.0, remove support for mixing in classes. Continue to allow mixins to appear in
extends
clauses.