@@ -53,29 +53,30 @@ Object? _generateEntry({
53
53
const TypeChecker .fromRuntime (JsonValue ).firstAnnotationOfExact (field);
54
54
55
55
if (annotation == null ) {
56
- if (jsonEnum.valueField != null ) {
56
+ final valueField = jsonEnum.valueField;
57
+ if (valueField != null ) {
57
58
// TODO: fieldRename is pointless here!!! At least log a warning!
58
59
59
60
final fieldElementType = field.type.element2 as EnumElement ;
60
61
61
- final e = fieldElementType.getField (jsonEnum. valueField! );
62
+ final e = fieldElementType.getField (valueField);
62
63
63
64
if (e == null || e.isStatic) {
64
65
throw InvalidGenerationSourceError (
65
- '`JsonEnum.valueField` was set to "${ jsonEnum . valueField } ", but '
66
+ '`JsonEnum.valueField` was set to "$valueField ", but '
66
67
'that is not a valid, instance field on '
67
68
'`${typeToCode (targetType )}`.' ,
68
69
element: targetType.element2,
69
70
);
70
71
}
71
72
72
73
final reader = ConstantReader (field.computeConstantValue ());
73
- final valueReader = reader.read (jsonEnum. valueField! );
74
+ final valueReader = reader.read (valueField);
74
75
if (valueReader.validValueType) {
75
76
return valueReader.literalValue;
76
77
} else {
77
78
throw InvalidGenerationSourceError (
78
- '`JsonEnum.valueField` was set to "${ jsonEnum . valueField } ", but '
79
+ '`JsonEnum.valueField` was set to "$valueField ", but '
79
80
'that field does not have a type of String, int, or null.' ,
80
81
element: targetType.element2,
81
82
);
0 commit comments