File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2148,19 +2148,19 @@ if (T != dynamic &&
21482148 }
21492149
21502150 /// Gets the expression for serializing an enum value in FormData as a string.
2151- /// Uses toJson() if available, otherwise uses .name .
2151+ /// Uses toJson() if available, otherwise uses toString() .
21522152 String _getEnumValueExpression (DartType enumType, String variableName) {
21532153 return _hasToJson (enumType)
21542154 ? '$variableName .toJson()'
2155- : '$variableName .name ' ;
2155+ : '$variableName .toString() ' ;
21562156 }
21572157
21582158 /// Gets the Reference for serializing an enum value in FormData.
2159- /// Uses toJson() if available, otherwise uses .name .
2159+ /// Uses toJson() if available, otherwise uses toString() .
21602160 Expression _getEnumValueReference (DartType enumType, String variableName) {
21612161 return _hasToJson (enumType)
21622162 ? refer (variableName).property ('toJson' ).call ([])
2163- : refer (variableName).property ('name' );
2163+ : refer (variableName).property ('toString' ). call ([] );
21642164 }
21652165
21662166 /// Generates the query parameters code block.
Original file line number Diff line number Diff line change @@ -1583,14 +1583,14 @@ enum TestEnumWithToJson {
15831583 final _data = FormData.fromMap(map);
15841584''' , contains: true )
15851585@ShouldGenerate ('''
1586- _data.fields.add(MapEntry('enumValue', enumValue.name ));
1586+ _data.fields.add(MapEntry('enumValue', enumValue.toString() ));
15871587''' , contains: true )
15881588@ShouldGenerate ('''
15891589 _data.fields.add(MapEntry('enumValue', enumValue.toJson()));
15901590''' , contains: true )
15911591@ShouldGenerate ('''
15921592 enumValues.forEach((i) {
1593- _data.fields.add(MapEntry('enumValues', i.name ));
1593+ _data.fields.add(MapEntry('enumValues', i.toString() ));
15941594 });
15951595''' , contains: true )
15961596@ShouldGenerate ('''
You can’t perform that action at this time.
0 commit comments