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
:
abstract sealed class C {}
Common fixes
#
If the class should be abstract but not sealed, then remove the
sealed
modifier:
abstract class C {}
If the class should be both abstract and sealed, then remove the
abstract
modifier:
sealed class C {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.