Skip to content

Commit dad68cb

Browse files
authored
Merge pull request #9809 from MichaelMarner/dart-double-cast
#9808 - Dart double cast
2 parents aa1f65d + 5c85257 commit dad68cb

File tree

7 files changed

+11
-6
lines changed

7 files changed

+11
-6
lines changed

modules/swagger-codegen/src/main/resources/dart/class.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ class {{classname}} {
2828
(json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList()
2929
{{/isListContainer}}
3030
{{^isListContainer}}
31+
{{#isDouble}}
32+
json['{{baseName}}'] == null ? null : json['{{baseName}}'].toDouble()
33+
{{/isDouble}}
34+
{{^isDouble}}
3135
json['{{baseName}}']
36+
{{/isDouble}}
3237
{{/isListContainer}}
3338
{{/complexType}};
3439
{{/isDateTime}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3-SNAPSHOT
1+
2.4.10-SNAPSHOT

samples/client/petstore/dart/flutter_petstore/swagger/lib/model/amount.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Amount {
1717
Amount.fromJson(Map<String, dynamic> json) {
1818
if (json == null) return;
1919
value =
20-
json['value']
20+
json['value'] == null ? null : json['value'].toDouble()
2121
;
2222
currency =
2323

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3-SNAPSHOT
1+
2.4.10-SNAPSHOT

samples/client/petstore/dart/swagger-browser-client/lib/model/amount.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Amount {
1717
Amount.fromJson(Map<String, dynamic> json) {
1818
if (json == null) return;
1919
value =
20-
json['value']
20+
json['value'] == null ? null : json['value'].toDouble()
2121
;
2222
currency =
2323

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3-SNAPSHOT
1+
2.4.10-SNAPSHOT

samples/client/petstore/dart/swagger/lib/model/amount.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Amount {
1717
Amount.fromJson(Map<String, dynamic> json) {
1818
if (json == null) return;
1919
value =
20-
json['value']
20+
json['value'] == null ? null : json['value'].toDouble()
2121
;
2222
currency =
2323

0 commit comments

Comments
 (0)