forked from loafle/openapi-generator-original
[Dart2] Added better double handling to 'mapValueOfType<T>', which previously would fail when deserding doubles (#17808)
This commit is contained in:
parent
6bc8e0bffc
commit
bfcfc6ff25
@ -69,6 +69,9 @@ Future<String> _decodeBodyBytes(Response response) async {
|
|||||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||||
T? mapValueOfType<T>(dynamic map, String key) {
|
T? mapValueOfType<T>(dynamic map, String key) {
|
||||||
final dynamic value = map is Map ? map[key] : null;
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
if (T == double && value is int) {
|
||||||
|
return value.toDouble() as T;
|
||||||
|
}
|
||||||
return value is T ? value : null;
|
return value is T ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,9 @@ Future<String> _decodeBodyBytes(Response response) async {
|
|||||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||||
T? mapValueOfType<T>(dynamic map, String key) {
|
T? mapValueOfType<T>(dynamic map, String key) {
|
||||||
final dynamic value = map is Map ? map[key] : null;
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
if (T == double && value is int) {
|
||||||
|
return value.toDouble() as T;
|
||||||
|
}
|
||||||
return value is T ? value : null;
|
return value is T ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,9 @@ Future<String> _decodeBodyBytes(Response response) async {
|
|||||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||||
T? mapValueOfType<T>(dynamic map, String key) {
|
T? mapValueOfType<T>(dynamic map, String key) {
|
||||||
final dynamic value = map is Map ? map[key] : null;
|
final dynamic value = map is Map ? map[key] : null;
|
||||||
|
if (T == double && value is int) {
|
||||||
|
return value.toDouble() as T;
|
||||||
|
}
|
||||||
return value is T ? value : null;
|
return value is T ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user