-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[dart-dio] fixes Enum classes with integer values #8129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ class {{classname}}{{nameInCamelCase}} extends EnumClass { | |
| {{#description}} | ||
| /// {{description}} | ||
| {{/description}} | ||
| @BuiltValueEnumConst(wireName: {{{value}}}) | ||
| @BuiltValueEnumConst({{#isInteger}}wireNumber: {{{value}}}{{/isInteger}}{{#isString}}wireName: {{{value}}}{{/isString}}) | ||
| static const {{classname}}{{nameInCamelCase}} {{name}} = _${{name}}; | ||
| {{/enumVars}} | ||
| {{/allowableValues}} | ||
|
|
@@ -16,4 +16,4 @@ class {{classname}}{{nameInCamelCase}} extends EnumClass { | |
|
|
||
| static BuiltSet<{{classname}}{{nameInCamelCase}}> get values => _${{classVarName}}{{nameInCamelCase}}Values; | ||
| static {{classname}}{{nameInCamelCase}} valueOf(String name) => _${{classVarName}}{{nameInCamelCase}}ValueOf(name); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably revert this line |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,3 +60,4 @@ class OrderStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,3 +62,4 @@ class PetStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,3 +60,4 @@ class OrderStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,3 +62,4 @@ class PetStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,7 @@ class EnumTestEnumString extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| class EnumTestEnumStringRequired extends EnumClass { | ||
|
|
||
| @BuiltValueEnumConst(wireName: 'UPPER') | ||
|
|
@@ -94,11 +95,12 @@ class EnumTestEnumStringRequired extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| class EnumTestEnumInteger extends EnumClass { | ||
|
|
||
| @BuiltValueEnumConst(wireName: 1) | ||
| @BuiltValueEnumConst(wireNumber: 1) | ||
| static const EnumTestEnumInteger number1 = _$number1; | ||
| @BuiltValueEnumConst(wireName: -1) | ||
| @BuiltValueEnumConst(wireNumber: -1) | ||
| static const EnumTestEnumInteger number1 = _$number1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI just noticed 2 times |
||
|
|
||
| static Serializer<EnumTestEnumInteger> get serializer => _$enumTestEnumIntegerSerializer; | ||
|
|
@@ -110,11 +112,12 @@ class EnumTestEnumInteger extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| class EnumTestEnumNumber extends EnumClass { | ||
|
|
||
| @BuiltValueEnumConst(wireName: '1.1') | ||
| @BuiltValueEnumConst() | ||
| static const EnumTestEnumNumber 11_ = _$11_; | ||
| @BuiltValueEnumConst(wireName: '-1.2') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above comment in template. Sadly |
||
| @BuiltValueEnumConst() | ||
| static const EnumTestEnumNumber 12_ = _$12_; | ||
|
|
||
| static Serializer<EnumTestEnumNumber> get serializer => _$enumTestEnumNumberSerializer; | ||
|
|
@@ -126,3 +129,4 @@ class EnumTestEnumNumber extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,3 +47,4 @@ class MapTestMapOfEnumString extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,3 +60,4 @@ class OrderStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,3 +62,4 @@ class PetStatus extends EnumClass { | |
| } | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
{{^isInteger}}to prevent thedoubleenum from failing.