avoid-duplicate-initializers
preset: recommended
Warns when a final variable has the same initializer as another variable in scope.
Variables with duplicate initializers are either the result of a typo or are redundant and can be simply removed.
Example
❌ Bad:
void fn(SomeClass param) {
final myValue = param.value.isNotEmpty;
// LINT: This variable has the same initializer as 'myValue'. Try changing the initializer or reusing the existing variable.
final anotherValue = param.value.isNotEmpty;
}
✅ Good:
void fn(SomeClass param) {
final myValue = param.value.isNotEmpty;
final anotherValue = param.anotherValue; // Correct, different initializer
}