avoid-map-keys-contains
preset: recommended
Warns when Map's .keys.contains
is used instead of containsKey
.
.keys.contains
is 6000 times slower than containsKey
and should be avoided.
Additional resources:
Example
❌ Bad:
void main() {
final map = {'hello': 'world'};
map.keys.contains('hello'); // LINT
}
✅ Good:
void main() {
final map = {'hello': 'world'};
map.containsKey('hello');
}