avoid-duplicate-cascades
Warns when a cascade expression has duplicated cascades.
Example
❌ Bad:
void fn() {
final value = SomeClass();
value
..field = '2' // LINT
..field = '1' // LINT
..field = '1' // LINT
..another = '1';
value
..method(() => 1) // LINT
..method(() => 1) // LINT
..method(() => 2);
final list = [1, 2, 3];
list
..[1] = 2 // LINT
..[1] = 2 // LINT
..[1] = 3 // LINT
..[2] = 2;
}
class SomeClass {
String? field;
String? another;
void method(Function callback) {}
}
✅ Good:
void fn() {
final value = SomeClass();
value
..field = '2'
..another = '1';
value
..method(() => 1)
..method(() => 2);
final list = [1, 2, 3];
list
..[1] = 2;
..[2] = 3;
}
class SomeClass {
String? field;
String? another;
void method(Function callback) {}
}