super_in_extension
The 'super' keyword can't be used in an extension because an extension doesn't have a superclass.
Description
#The analyzer produces this diagnostic when a member declared inside an extension uses the super
keyword . Extensions aren't classes and don't have superclasses, so the super
keyword serves no purpose.
Example
#The following code produces this diagnostic because super
can't be used in an extension:
dart
extension E on Object {
String get displayString => super.toString();
}
Common fixes
#Remove the super
keyword :
dart
extension E on Object {
String get displayString => toString();
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.