must_call_super
This method overrides a method annotated as '@mustCallSuper' in '{0}', but doesn't invoke the overridden method.
Description
#The analyzer produces this diagnostic when a method that overrides a method that is annotated as mustCallSuper
doesn't invoke the overridden method as required.
Example
#The following code produces this diagnostic because the method m
in B
doesn't invoke the overridden method m
in A
:
import 'package:meta/meta.dart';
class A {
@mustCallSuper
m() {}
}
class B extends A {
@override
m() {}
}
Common fixes
#Add an invocation of the overridden method in the overriding method:
import 'package:meta/meta.dart';
class A {
@mustCallSuper
m() {}
}
class B extends A {
@override
m() {
super.m();
}
}
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.