avoid-missing-enum-constant-in-map
preset: recommended
Warns when a enum constant is missing in a map declaration.
Example
❌ Bad:
enum SomeEnum {
firstEntry,
secondEntry,
thirdEntry,
}
extension SomeX on SomeEnum {
// LINT: Missing map entry for 'thirdEntry'.
static const firstMap = <SomeEnum, String>{
CountyCode.firstEntry: 'foo',
CountyCode.secondEntry: 'bar',
};
// LINT: Missing map entry for 'secondEntry' and 'thirdEntry'.
static const secondMap = <SomeEnum, String>{
CountyCode.firstEntry: 'foo',
};
}
✅ Good:
extension SomeX on SomeEnum {
// Correct, uses all enum constants
static const firstMap = <SomeEnum, String>{
CountyCode.firstEntry: 'foo',
CountyCode.secondEntry: 'bar',
CountyCode.thirdEntry: 'baz',
};
// Correct, uses all enum constants
static const secondMap = <SomeEnum, String>{
CountyCode.firstEntry: 'foo',
CountyCode.secondEntry: 'bar',
CountyCode.thirdEntry: 'baz',
};
}