subtype_ of_ disallowed_ type
Details about the 'subtype_of_disallowed_type' diagnostic produced by the Dart analyzer.
'{0}' can't be used as a superclass constraint.
Classes and mixins can't implement '{0}'.
Classes can't extend '{0}'.
Classes can't mixin '{0}'.
Description
#
The analyzer produces this diagnostic when one of the
restricted classes is used in either an extends,
implements, with, or
on clause. The classes bool,
double, FutureOr, int,
Null, num, and String
are all restricted in this way, to allow for more efficient
implementations.
Examples
#
The following code produces this diagnostic because
String is used in an extends clause:
class A extends String {}
The following code produces this diagnostic because
String is used in an
implements clause:
class B implements String {}
The following code produces this diagnostic because
String is used in a with clause:
class C with String {}
The following code produces this diagnostic because
String is used in an on clause:
mixin M on String {}
Common fixes
#If a different type should be specified, then replace the type:
class A extends Object {}
If there isn't a different type that would be appropriate, then remove the type, and possibly the whole clause:
class B {}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.