Skip to main content

avoid-suspicious-super-overrides

added in: 1.21.0
🛠
Pro+
preset: recommended

Warns when a getter overrides a field that is already passed to the super constructor.

Example

❌ Bad:

sealed class DependencyIssue {
final String issueType;

const DependencyIssue({
required this.issueType,
});
}

class First extends DependencyIssue {
final String packageName;


String get issueType => 'hi'; // LINT: This getter overrides a field that is already passed to the super constructor. Consider removing it or referencing the super field.

const First({
required this.packageName,
}) : super(issueType: 'promotion');
}

✅ Good:

sealed class DependencyIssue {
final String issueType;

const DependencyIssue({
required this.issueType,
});
}

class First extends DependencyIssue {
final String packageName;

const First({
required this.packageName,
}) : super(issueType: 'promotion');
}