subtype_of_sealed_class
The class '{0}' shouldn't be extended, mixed in, or implemented because it's sealed.
Description
#The analyzer produces this diagnostic when a sealed class (one that either
has the sealed
annotation or inherits or mixes in a
sealed class) is referenced in either the extends
, implements
, or
with
clause of a class or mixin declaration if the declaration isn't in
the same package as the sealed class.
Example
#Given a library in a package other than the package being analyzed that contains the following:
import 'package:meta/meta.dart';
class A {}
@sealed
class B {}
The following code produces this diagnostic because C
, which isn't in the
same package as B
, is extending the sealed class B
:
import 'package:a/a.dart';
class C extends B {}
Common fixes
#If the class doesn't need to be a subtype of the sealed class, then change the declaration so that it isn't:
import 'package:a/a.dart';
class B extends A {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。