From 30f37b4dd8d33e2e6e70ecbbd6b81255d9e86ab6 Mon Sep 17 00:00:00 2001 From: Martynas Zabulionis Date: Thu, 18 Jul 2024 12:19:26 +0300 Subject: [PATCH] fix: fix enum generation #663 --- generator/lib/src/generator.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generator/lib/src/generator.dart b/generator/lib/src/generator.dart index c6f5a8e3..53ebaf25 100644 --- a/generator/lib/src/generator.dart +++ b/generator/lib/src/generator.dart @@ -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) {')); } @@ -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([]) ])