specify-unknown-enum-value
Warns when a field of the Enum type does not specify unknownEnumValue.
Specifying unknownEnumValue ensures backward compatibility if the enum values change. Not providing it can lead to runtime exceptions for older app versions if it relies on the same API.
Example
❌ Bad:
()
class MyEntity {
// LINT: Fields of the Enum type must specify 'unknownEnumValue' to simplify backward compatibility.
// Try adding '@JsonKey' with 'unknownEnumValue'.
final MyEnum myEnum;
}
()
class MyEntity {
// LINT: Fields of the Enum type must specify 'unknownEnumValue' to simplify backward compatibility.
// Try adding '@JsonKey' with 'unknownEnumValue'.
()
final MyEnum myEnum;
}
✅ Good:
()
class MyEntity {
(unknownEnumValue: MyEnum.a)
final MyEnum myEnum;
}
()
class MyEntity {
(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
final MyEnum? myEnum;
}