avoid-unused-generics
preset: recommended
Warns when a function or method declares unused generic types.
⚙️ Config
Set ignore-overridden
(default is false
) to ignore methods that have the @override
annotation.
dart_code_metrics:
...
rules:
...
- avoid-unused-generics:
ignore-overridden: true
Example
❌ Bad:
class SomeClass {
// LINT
String unused<T extends num>() {
// ...
}
// LINT
String multiple<T, U>(U param) {
// ...
}
}
// LINT
void function<T>() {
return;
}
✅ Good:
class SomeClass {
String used<T extends num>() {
return (value as T).toString();
}
T multiple<T, U>(U param) {
// ...
}
}
void function() {
return;
}