Group: style
Maturity: stable
Dart SDK: >= 2.0.0 • (Linter v0.1.31)
Since info is static, may be staleDON'T define a setter without a corresponding getter.
Defining a setter without defining a corresponding getter can lead to logical inconsistencies. Doing this could allow you to set a property to some value, but then upon observing the property's value, it could easily be different.
BAD:
class Bad {
int l, r;
set length(int newLength) {
r = l + newLength;
}
}
GOOD:
class Good {
int l, r;
int get length => r - l;
set length(int newLength) {
r = l + newLength;
}
}
To enable the avoid_setters_without_getters
lint,
add avoid_setters_without_getters
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- avoid_setters_without_getters