abstract_sealed_class
A 'sealed' class can't be marked 'abstract' because it's already implicitly abstract.
Description
#The analyzer produces this diagnostic when a class is declared using both
the modifier abstract
and the modifier sealed
. Sealed classes are
implicitly abstract, so explicitly using both modifiers is not allowed.
Example
#The following code produces this diagnostic because the class C
is
declared using both abstract
and sealed
:
dart
abstract sealed class C {}
Common fixes
#If the class should be abstract but not sealed, then remove the sealed
modifier:
dart
abstract class C {}
If the class should be both abstract and sealed, then remove the
abstract
modifier:
dart
sealed class C {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。