Skip to content

Commit

Permalink
Fix conditional with redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
millsteed committed Jan 29, 2024
1 parent ad2872a commit f49e360
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/model.dart
Expand Up @@ -16,7 +16,7 @@ macro class Model implements ClassDeclarationsMacro {
MemberDeclarationBuilder builder,
) async {
final className = classDeclaration.identifier.name;

final fields = await builder.fieldsOf(classDeclaration);

final fieldNames = <String>[];
Expand Down Expand Up @@ -71,8 +71,7 @@ macro class Model implements ClassDeclarationsMacro {
if (_baseTypes.contains(fieldTypes[fieldName])) ...[
"$fieldName: json['$fieldName'] as ${fieldTypes[fieldName]},"
.indent(6),
] else if (_collectionTypes
.contains(fieldTypes[fieldName]?.split('<').first)) ...[
] else if (_collectionTypes.contains(fieldTypes[fieldName])) ...[
"$fieldName: (json['$fieldName'] as List<dynamic>)".indent(6),
'.whereType<Map<String, dynamic>>()'.indent(10),
'.map(${fieldGenerics[fieldName]?.first}.fromJson)'.indent(10),
Expand Down

0 comments on commit f49e360

Please sign in to comment.