Dart Replaces With by Using Implements

Created At: 2023-06-23 18:33:32 Updated At: 2023-06-23 18:41:38

The class 'PreferredSizeWidget' can't be used as a mixin because it's neither a mixin class nor a mixin

In Dart 3, the rules around mixins have been made stricter compared to previous versions. As mentioned in the release notes, any class could be used as a mixin before Dart 3, as long as it had no declared constructors and no superclass other than Object.

In Dart 3, classes declared in libraries at language version 3.0 or later can't be used as mixins unless they are explicitly marked with the mixin keyword.

So, PreferredSizeWidget is not declared as a mixin and does not have the mixin keyword in its definition. This is why the error is encountered when using it as a mixin.


Add Reviews