subtype_of_deferred_class
Classes and mixins can't implement deferred classes.
Classes can't extend deferred classes.
Classes can't mixin deferred classes.
Description
#The analyzer produces this diagnostic when a type (class or mixin) is a subtype of a class from a library being imported using a deferred import. The supertypes of a type must be compiled at the same time as the type, and classes from deferred libraries aren't compiled until the library is loaded.
For more information, check out Lazily loading a library.
Example
#Given a file a.dart
that defines the class A
:
class A {}
The following code produces this diagnostic because the superclass of B
is declared in a deferred library:
import 'a.dart' deferred as a;
class B extends a.A {}
Common fixes
#If you need to create a subtype of a type from the deferred library, then remove the deferred
keyword:
import 'a.dart' as a;
class B extends a.A {}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.