sdk
sdk copied to clipboard
unused_field improvement: detect self-assignment
class Counter extends ChangeNotifier {
int _counter = 0;
void increment() {
_counter = 1;
}
void reset() {
_counter = 0;
}
}
The value of the field '_counter' isn't used. Try removing the field, or using it.
but
class Counter extends ChangeNotifier {
int _counter = 0;
void increment() {
_counter = _counter + 1;
// _counter = _counter; is enough to make the warning disappear
}
void reset() {
_counter = 0;
}
}
now unused_field is happy but _counter is still an unused field in my opinion because it is used for a self-assignment