Skip to content

Commit

Permalink
fix: fix enum generation #663
Browse files Browse the repository at this point in the history
  • Loading branch information
MartynasZabulionis committed Jul 18, 2024
1 parent b24d210 commit 30f37b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ ${bodyName.displayName} == null
} else {
throw Exception('Unknown error!');
}
} else if (_isBasicType(p.type)) {
} else if (_isBasicType(p.type) || _isEnum(p.type)) {
if (p.type.nullabilitySuffix == NullabilitySuffix.question) {
blocks.add(Code('if (${p.displayName} != null) {'));
}
Expand All @@ -2009,6 +2009,8 @@ ${bodyName.displayName} == null
literal(fieldName),
if (_typeChecker(String).isExactlyType(p.type))
refer(p.displayName)
else if (_isEnum(p.type))
refer(p.displayName).property('name')
else
refer(p.displayName).property('toString').call([])
])
Expand Down

0 comments on commit 30f37b4

Please sign in to comment.