Skip to content

Commit

Permalink
Support array of enums in Dart factories
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Mar 1, 2023
1 parent 3a15620 commit ae6bed1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Language/Dart/DartClassFactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private function resolveFactoryProperty(
if ($dtoType->isStringEnum()) {
return sprintf("%s.values.byName({$mapArgumentName})", $type->getName(), $propertyName);
}
return sprintf("%s.values[{$mapArgumentName}]]", $type->getName(), $propertyName);
return sprintf("%s.values[{$mapArgumentName}]", $type->getName(), $propertyName);
}

return sprintf("%s.fromJson({$mapArgumentName})", $type->getName(), $propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class User extends Equatable {
recipeRequired: Recipe.fromJson(json['recipeRequired']),
friendsRequired: List<User>.from(json['friendsRequired'].map((e) => User.fromJson(e))),
friendsOptional: json['friendsOptional'] != null ? List<User>.from(json['friendsOptional'].map((e) => User.fromJson(e))) : null,
themeColor: ColorEnum.values[json['themeColor']]],
colors: List<ColorEnum>.from(json['colors'].map((e) => ColorEnum.values[e]])),
enumInt: DayOfTheWeekEnumBackedInt.values[json['enumInt']]],
themeColor: ColorEnum.values[json['themeColor']],
colors: List<ColorEnum>.from(json['colors'].map((e) => ColorEnum.values[e])),
enumInt: DayOfTheWeekEnumBackedInt.values[json['enumInt']],
enumString: DayOfTheWeekEnumBackedString.values.byName(json['enumString']),
);
}
Expand Down

0 comments on commit ae6bed1

Please sign in to comment.