From a47a0a89f726268bf44450322964826ec450b23e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 23 Apr 2024 16:02:30 -0700 Subject: [PATCH] rebuild and add test --- .../test/default_value/default_value.g.dart | 10 +- .../default_value.g_any_map__checked.g.dart | 15 +- .../implicit_default_value.g.dart | 10 +- .../field_matrix_test.field_matrix.g.dart | 88 ++++----- .../generic_argument_factories.g.dart | 2 +- ...generic_argument_factories_nullable.g.dart | 2 +- .../test/generic_files/generic_class.g.dart | 6 +- .../integration/converter_examples.g.dart | 2 +- .../create_per_field_to_json_example.g.dart | 2 +- .../test/integration/integration_test.dart | 8 + .../test/integration/json_test_example.g.dart | 32 ++-- .../json_test_example.g_any_map.g.dart | 32 ++-- .../test/kitchen_sink/kitchen_sink.g.dart | 39 ++-- .../kitchen_sink.g_any_map.g.dart | 39 ++-- .../kitchen_sink.g_any_map__checked.g.dart | 51 ++--- .../kitchen_sink.g_exclude_null.g.dart | 39 ++-- .../kitchen_sink.g_explicit_to_json.g.dart | 39 ++-- .../test/kitchen_sink/simple_object.g.dart | 2 +- .../kitchen_sink/strict_keys_object.g.dart | 2 +- .../input.type_duration.g.dart | 4 +- .../supported_types/input.type_int.g.dart | 8 +- .../input.type_iterable.g.dart | 24 +-- .../supported_types/input.type_list.g.dart | 28 ++- .../supported_types/input.type_map.g.dart | 178 +++++++++--------- .../supported_types/input.type_record.g.dart | 41 ++-- .../supported_types/input.type_set.g.dart | 24 ++- .../tool/readme/readme_examples.g.dart | 6 +- 27 files changed, 410 insertions(+), 323 deletions(-) diff --git a/json_serializable/test/default_value/default_value.g.dart b/json_serializable/test/default_value/default_value.g.dart index 0614284e6..6bc4525d5 100644 --- a/json_serializable/test/default_value/default_value.g.dart +++ b/json_serializable/test/default_value/default_value.g.dart @@ -11,13 +11,13 @@ part of 'default_value.dart'; DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( json['fieldBool'] as bool? ?? true, json['fieldString'] as String? ?? 'string', - json['fieldInt'] as int? ?? 42, + (json['fieldInt'] as num?)?.toInt() ?? 42, (json['fieldDouble'] as num?)?.toDouble() ?? 3.14, json['fieldListEmpty'] as List? ?? [], (json['fieldSetEmpty'] as List?)?.toSet() ?? {}, json['fieldMapEmpty'] as Map? ?? {}, (json['fieldListSimple'] as List?) - ?.map((e) => e as int) + ?.map((e) => (e as num).toInt()) .toList() ?? [1, 2, 3], (json['fieldSetSimple'] as List?) @@ -25,7 +25,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( .toSet() ?? {'entry1', 'entry2'}, (json['fieldMapSimple'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ) ?? {'answer': 42}, (json['fieldMapListString'] as Map?)?.map( @@ -38,7 +38,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( $enumDecodeNullable(_$GreekEnumMap, json['fieldEnum']) ?? Greek.beta, durationField: json['durationField'] == null ? Duration.zero - : Duration(microseconds: json['durationField'] as int), + : Duration(microseconds: (json['durationField'] as num).toInt()), constClass: json['constClass'] == null ? const ConstClass('value') : ConstClass.fromJson(json['constClass'] as Map), @@ -50,7 +50,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( ? const ConstClass('value') : constClassFromJson(json['valueFromFunction'] as String), intDefaultValueFromFunction: - json['intDefaultValueFromFunction'] as int? ?? + (json['intDefaultValueFromFunction'] as num?)?.toInt() ?? intDefaultValueFunction(), valueFromDefaultValueDefaultConstructor: json['valueFromDefaultValueDefaultConstructor'] == null diff --git a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart index 24be86d8a..9ce12321f 100644 --- a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart +++ b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart @@ -15,7 +15,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( final val = DefaultValue( $checkedConvert('fieldBool', (v) => v as bool? ?? true), $checkedConvert('fieldString', (v) => v as String? ?? 'string'), - $checkedConvert('fieldInt', (v) => v as int? ?? 42), + $checkedConvert('fieldInt', (v) => (v as num?)?.toInt() ?? 42), $checkedConvert( 'fieldDouble', (v) => (v as num?)?.toDouble() ?? 3.14), $checkedConvert('fieldListEmpty', (v) => v as List? ?? []), @@ -25,7 +25,9 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( $checkedConvert( 'fieldListSimple', (v) => - (v as List?)?.map((e) => e as int).toList() ?? + (v as List?) + ?.map((e) => (e as num).toInt()) + .toList() ?? [1, 2, 3]), $checkedConvert( 'fieldSetSimple', @@ -36,7 +38,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( 'fieldMapSimple', (v) => (v as Map?)?.map( - (k, e) => MapEntry(k as String, e as int), + (k, e) => MapEntry(k as String, (e as num).toInt()), ) ?? {'answer': 42}), $checkedConvert( @@ -53,8 +55,9 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( (v) => $enumDecodeNullable(_$GreekEnumMap, v) ?? Greek.beta), durationField: $checkedConvert( 'durationField', - (v) => - v == null ? Duration.zero : Duration(microseconds: v as int)), + (v) => v == null + ? Duration.zero + : Duration(microseconds: (v as num).toInt())), constClass: $checkedConvert( 'constClass', (v) => v == null @@ -72,7 +75,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( : constClassFromJson(v as String)), intDefaultValueFromFunction: $checkedConvert( 'intDefaultValueFromFunction', - (v) => v as int? ?? intDefaultValueFunction()), + (v) => (v as num?)?.toInt() ?? intDefaultValueFunction()), valueFromDefaultValueDefaultConstructor: $checkedConvert( 'valueFromDefaultValueDefaultConstructor', (v) => v == null diff --git a/json_serializable/test/default_value/implicit_default_value.g.dart b/json_serializable/test/default_value/implicit_default_value.g.dart index 9bd1f19e0..408c1f0b2 100644 --- a/json_serializable/test/default_value/implicit_default_value.g.dart +++ b/json_serializable/test/default_value/implicit_default_value.g.dart @@ -13,14 +13,14 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( DefaultValueImplicit( fieldBool: json['fieldBool'] as bool? ?? true, fieldString: json['fieldString'] as String? ?? 'string', - fieldInt: json['fieldInt'] as int? ?? 42, + fieldInt: (json['fieldInt'] as num?)?.toInt() ?? 42, fieldDouble: (json['fieldDouble'] as num?)?.toDouble() ?? 3.14, fieldListEmpty: json['fieldListEmpty'] as List? ?? const [], fieldSetEmpty: (json['fieldSetEmpty'] as List?)?.toSet() ?? const {}, fieldMapEmpty: json['fieldMapEmpty'] as Map? ?? const {}, fieldListSimple: (json['fieldListSimple'] as List?) - ?.map((e) => e as int) + ?.map((e) => (e as num).toInt()) .toList() ?? const [1, 2, 3], fieldSetSimple: (json['fieldSetSimple'] as List?) @@ -28,7 +28,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( .toSet() ?? const {'entry1', 'entry2'}, fieldMapSimple: (json['fieldMapSimple'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ) ?? const {'answer': 42}, fieldMapListString: @@ -43,7 +43,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( $enumDecodeNullable(_$GreekEnumMap, json['fieldEnum']) ?? Greek.beta, durationField: json['durationField'] == null ? const Duration() - : Duration(microseconds: json['durationField'] as int), + : Duration(microseconds: (json['durationField'] as num).toInt()), constClass: json['constClass'] == null ? const ConstClass('value') : ConstClass.fromJson(json['constClass'] as Map), @@ -55,7 +55,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( ? const ConstClass('value') : constClassFromJson(json['valueFromFunction'] as String), intDefaultValueFromFunction: - json['intDefaultValueFromFunction'] as int? ?? 43, + (json['intDefaultValueFromFunction'] as num?)?.toInt() ?? 43, valueFromDefaultValueDefaultConstructor: json['valueFromDefaultValueDefaultConstructor'] == null ? const ConstClass() diff --git a/json_serializable/test/field_matrix_test.field_matrix.g.dart b/json_serializable/test/field_matrix_test.field_matrix.g.dart index 09895c99b..aa18728ba 100644 --- a/json_serializable/test/field_matrix_test.field_matrix.g.dart +++ b/json_serializable/test/field_matrix_test.field_matrix.g.dart @@ -12,8 +12,8 @@ ToJsonNullFromJsonNullPublic _$ToJsonNullFromJsonNullPublicFromJson( Map json) => ToJsonNullFromJsonNullPublic() ..aField = (json['aField'] as num?)?.toInt() - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonNullPublicToJson( ToJsonNullFromJsonNullPublic instance) => @@ -26,9 +26,9 @@ Map _$ToJsonNullFromJsonNullPublicToJson( ToJsonNullFromJsonTruePublic _$ToJsonNullFromJsonTruePublicFromJson( Map json) => ToJsonNullFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonTruePublicToJson( ToJsonNullFromJsonTruePublic instance) => @@ -41,8 +41,8 @@ Map _$ToJsonNullFromJsonTruePublicToJson( ToJsonNullFromJsonFalsePublic _$ToJsonNullFromJsonFalsePublicFromJson( Map json) => ToJsonNullFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonFalsePublicToJson( ToJsonNullFromJsonFalsePublic instance) => @@ -54,9 +54,9 @@ Map _$ToJsonNullFromJsonFalsePublicToJson( ToJsonTrueFromJsonNullPublic _$ToJsonTrueFromJsonNullPublicFromJson( Map json) => ToJsonTrueFromJsonNullPublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonNullPublicToJson( ToJsonTrueFromJsonNullPublic instance) => @@ -69,9 +69,9 @@ Map _$ToJsonTrueFromJsonNullPublicToJson( ToJsonTrueFromJsonTruePublic _$ToJsonTrueFromJsonTruePublicFromJson( Map json) => ToJsonTrueFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonTruePublicToJson( ToJsonTrueFromJsonTruePublic instance) => @@ -84,8 +84,8 @@ Map _$ToJsonTrueFromJsonTruePublicToJson( ToJsonTrueFromJsonFalsePublic _$ToJsonTrueFromJsonFalsePublicFromJson( Map json) => ToJsonTrueFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonFalsePublicToJson( ToJsonTrueFromJsonFalsePublic instance) => @@ -98,9 +98,9 @@ Map _$ToJsonTrueFromJsonFalsePublicToJson( ToJsonFalseFromJsonNullPublic _$ToJsonFalseFromJsonNullPublicFromJson( Map json) => ToJsonFalseFromJsonNullPublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonNullPublicToJson( ToJsonFalseFromJsonNullPublic instance) => @@ -112,9 +112,9 @@ Map _$ToJsonFalseFromJsonNullPublicToJson( ToJsonFalseFromJsonTruePublic _$ToJsonFalseFromJsonTruePublicFromJson( Map json) => ToJsonFalseFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonTruePublicToJson( ToJsonFalseFromJsonTruePublic instance) => @@ -126,8 +126,8 @@ Map _$ToJsonFalseFromJsonTruePublicToJson( ToJsonFalseFromJsonFalsePublic _$ToJsonFalseFromJsonFalsePublicFromJson( Map json) => ToJsonFalseFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonFalsePublicToJson( ToJsonFalseFromJsonFalsePublic instance) => @@ -139,8 +139,8 @@ Map _$ToJsonFalseFromJsonFalsePublicToJson( ToJsonNullFromJsonNullPrivate _$ToJsonNullFromJsonNullPrivateFromJson( Map json) => ToJsonNullFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonNullPrivateToJson( ToJsonNullFromJsonNullPrivate instance) => @@ -152,9 +152,9 @@ Map _$ToJsonNullFromJsonNullPrivateToJson( ToJsonNullFromJsonTruePrivate _$ToJsonNullFromJsonTruePrivateFromJson( Map json) => ToJsonNullFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonTruePrivateToJson( ToJsonNullFromJsonTruePrivate instance) => @@ -167,8 +167,8 @@ Map _$ToJsonNullFromJsonTruePrivateToJson( ToJsonNullFromJsonFalsePrivate _$ToJsonNullFromJsonFalsePrivateFromJson( Map json) => ToJsonNullFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonFalsePrivateToJson( ToJsonNullFromJsonFalsePrivate instance) => @@ -180,8 +180,8 @@ Map _$ToJsonNullFromJsonFalsePrivateToJson( ToJsonTrueFromJsonNullPrivate _$ToJsonTrueFromJsonNullPrivateFromJson( Map json) => ToJsonTrueFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonNullPrivateToJson( ToJsonTrueFromJsonNullPrivate instance) => @@ -194,9 +194,9 @@ Map _$ToJsonTrueFromJsonNullPrivateToJson( ToJsonTrueFromJsonTruePrivate _$ToJsonTrueFromJsonTruePrivateFromJson( Map json) => ToJsonTrueFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonTruePrivateToJson( ToJsonTrueFromJsonTruePrivate instance) => @@ -209,8 +209,8 @@ Map _$ToJsonTrueFromJsonTruePrivateToJson( ToJsonTrueFromJsonFalsePrivate _$ToJsonTrueFromJsonFalsePrivateFromJson( Map json) => ToJsonTrueFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonFalsePrivateToJson( ToJsonTrueFromJsonFalsePrivate instance) => @@ -223,8 +223,8 @@ Map _$ToJsonTrueFromJsonFalsePrivateToJson( ToJsonFalseFromJsonNullPrivate _$ToJsonFalseFromJsonNullPrivateFromJson( Map json) => ToJsonFalseFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonNullPrivateToJson( ToJsonFalseFromJsonNullPrivate instance) => @@ -236,9 +236,9 @@ Map _$ToJsonFalseFromJsonNullPrivateToJson( ToJsonFalseFromJsonTruePrivate _$ToJsonFalseFromJsonTruePrivateFromJson( Map json) => ToJsonFalseFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonTruePrivateToJson( ToJsonFalseFromJsonTruePrivate instance) => @@ -250,8 +250,8 @@ Map _$ToJsonFalseFromJsonTruePrivateToJson( ToJsonFalseFromJsonFalsePrivate _$ToJsonFalseFromJsonFalsePrivateFromJson( Map json) => ToJsonFalseFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonFalsePrivateToJson( ToJsonFalseFromJsonFalsePrivate instance) => diff --git a/json_serializable/test/generic_files/generic_argument_factories.g.dart b/json_serializable/test/generic_files/generic_argument_factories.g.dart index 188ac7116..3ae8ac8e1 100644 --- a/json_serializable/test/generic_files/generic_argument_factories.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories.g.dart @@ -34,7 +34,7 @@ ConcreteClass _$ConcreteClassFromJson(Map json) => ConcreteClass( GenericClassWithHelpers.fromJson( json['value'] as Map, - (value) => value as int, + (value) => (value as num).toInt(), (value) => value as String), GenericClassWithHelpers.fromJson( json['value2'] as Map, diff --git a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart index 17b278eed..626fa171a 100644 --- a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart @@ -56,7 +56,7 @@ ConcreteClassNullable _$ConcreteClassNullableFromJson( ConcreteClassNullable( GenericClassWithHelpersNullable.fromJson( json['value'] as Map, - (value) => value as int, + (value) => (value as num).toInt(), (value) => value as String), GenericClassWithHelpersNullable.fromJson( json['value2'] as Map, diff --git a/json_serializable/test/generic_files/generic_class.g.dart b/json_serializable/test/generic_files/generic_class.g.dart index c5809241c..ec35c1f1f 100644 --- a/json_serializable/test/generic_files/generic_class.g.dart +++ b/json_serializable/test/generic_files/generic_class.g.dart @@ -38,15 +38,15 @@ GenericClassWithConverter GenericClassWithConverter() ..fieldObject = json['fieldObject'] ..fieldDynamic = json['fieldDynamic'] - ..fieldInt = json['fieldInt'] as int? + ..fieldInt = (json['fieldInt'] as num?)?.toInt() ..fieldT = _$JsonConverterFromJson, T>( json['fieldT'], _SimpleConverter().fromJson) ..fieldS = _$JsonConverterFromJson, S>( json['fieldS'], _SimpleConverter().fromJson) ..duration = const _DurationMillisecondConverter.named() - .fromJson(json['duration'] as int?) + .fromJson((json['duration'] as num).toInt()) ..listDuration = const _DurationListMillisecondConverter() - .fromJson(json['listDuration'] as int?); + .fromJson((json['listDuration'] as num).toInt()); Map _$GenericClassWithConverterToJson( GenericClassWithConverter instance) => diff --git a/json_serializable/test/integration/converter_examples.g.dart b/json_serializable/test/integration/converter_examples.g.dart index 26da277f0..2829672a9 100644 --- a/json_serializable/test/integration/converter_examples.g.dart +++ b/json_serializable/test/integration/converter_examples.g.dart @@ -12,7 +12,7 @@ Issue1202RegressionClass _$Issue1202RegressionClassFromJson( Map json) => Issue1202RegressionClass( value: $enumDecode(_$Issue1202RegressionEnumEnumMap, json['value']), - normalNullableValue: json['normalNullableValue'] as int?, + normalNullableValue: (json['normalNullableValue'] as num?)?.toInt(), notNullableValueWithNullableConverter: const _Issue1202RegressionConverter().fromJson( json['notNullableValueWithNullableConverter'] as String?), diff --git a/json_serializable/test/integration/create_per_field_to_json_example.g.dart b/json_serializable/test/integration/create_per_field_to_json_example.g.dart index 0587c26ba..1c4b0fe88 100644 --- a/json_serializable/test/integration/create_per_field_to_json_example.g.dart +++ b/json_serializable/test/integration/create_per_field_to_json_example.g.dart @@ -23,7 +23,7 @@ Model _$ModelFromJson(Map json) => Model( ? null : GenericFactory.fromJson( json['nestedGeneric'] as Map, - (value) => value as int), + (value) => (value as num).toInt()), ); // ignore: unused_element diff --git a/json_serializable/test/integration/integration_test.dart b/json_serializable/test/integration/integration_test.dart index 8c5827ee8..4be3655f2 100644 --- a/json_serializable/test/integration/integration_test.dart +++ b/json_serializable/test/integration/integration_test.dart @@ -264,6 +264,14 @@ void main() { roundTripNumber(Numbers.fromJson(value)); }); + test('support doubles as ints', () { + final value = { + 'ints': [0, 0.0], + }; + + roundTripNumber(Numbers.fromJson(value)); + }); + test('does not support doubles as ints', () { final value = { 'ints': [3.14, 0], diff --git a/json_serializable/test/integration/json_test_example.g.dart b/json_serializable/test/integration/json_test_example.g.dart index b6a5330d4..4d8b42f37 100644 --- a/json_serializable/test/integration/json_test_example.g.dart +++ b/json_serializable/test/integration/json_test_example.g.dart @@ -29,7 +29,8 @@ Person _$PersonFromJson(Map json) => Person( (k, e) => MapEntry(k, $enumDecode(_$CategoryEnumMap, e)), ) ..categoryCounts = (json['categoryCounts'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$CategoryEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$CategoryEnumMap, k), (e as num).toInt()), ); Map _$PersonToJson(Person instance) => { @@ -66,11 +67,11 @@ Order _$OrderFromJson(Map json) { (json['items'] as List?) ?.map((e) => Item.fromJson(e as Map)), ) - ..count = json['count'] as int? + ..count = (json['count'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool? ..duration = json['duration'] == null ? null - : Duration(microseconds: json['duration'] as int) + : Duration(microseconds: (json['duration'] as num).toInt()) ..platform = json['platform'] == null ? null : Platform.fromJson(json['platform'] as String) @@ -113,13 +114,15 @@ const _$StatusCodeEnumMap = { }; Item _$ItemFromJson(Map json) => Item( - json['price'] as int?, + (json['price'] as num?)?.toInt(), ) - ..itemNumber = json['item-number'] as int? + ..itemNumber = (json['item-number'] as num?)?.toInt() ..saleDates = (json['saleDates'] as List?) ?.map((e) => DateTime.parse(e as String)) .toList() - ..rates = (json['rates'] as List?)?.map((e) => e as int).toList() + ..rates = (json['rates'] as List?) + ?.map((e) => (e as num).toInt()) + .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); Map _$ItemToJson(Item instance) { @@ -142,7 +145,8 @@ Map _$ItemToJson(Item instance) { } Numbers _$NumbersFromJson(Map json) => Numbers() - ..ints = (json['ints'] as List?)?.map((e) => e as int).toList() + ..ints = + (json['ints'] as List?)?.map((e) => (e as num).toInt()).toList() ..nums = (json['nums'] as List?)?.map((e) => e as num).toList() ..doubles = (json['doubles'] as List?) ?.map((e) => (e as num).toDouble()) @@ -150,8 +154,8 @@ Numbers _$NumbersFromJson(Map json) => Numbers() ..nnDoubles = (json['nnDoubles'] as List?) ?.map((e) => (e as num).toDouble()) .toList() - ..duration = durationFromInt(json['duration'] as int?) - ..date = dateTimeFromEpochUs(json['date'] as int?); + ..duration = durationFromInt((json['duration'] as num).toInt()) + ..date = dateTimeFromEpochUs((json['date'] as num).toInt()); Map _$NumbersToJson(Numbers instance) => { 'ints': instance.ints, @@ -165,16 +169,16 @@ Map _$NumbersToJson(Numbers instance) => { MapKeyVariety _$MapKeyVarietyFromJson(Map json) => MapKeyVariety() ..intIntMap = (json['intIntMap'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ) ..uriIntMap = (json['uriIntMap'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ) ..dateTimeIntMap = (json['dateTimeIntMap'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ) ..bigIntMap = (json['bigIntMap'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ); Map _$MapKeyVarietyToJson(MapKeyVariety instance) => @@ -204,7 +208,7 @@ UnknownEnumValue _$UnknownEnumValueFromJson(Map json) => PrivateConstructor _$PrivateConstructorFromJson(Map json) => PrivateConstructor._( - json['id'] as int, + (json['id'] as num).toInt(), json['value'] as String, ); diff --git a/json_serializable/test/integration/json_test_example.g_any_map.g.dart b/json_serializable/test/integration/json_test_example.g_any_map.g.dart index b8ba1f9f4..f57a51630 100644 --- a/json_serializable/test/integration/json_test_example.g_any_map.g.dart +++ b/json_serializable/test/integration/json_test_example.g_any_map.g.dart @@ -29,7 +29,8 @@ Person _$PersonFromJson(Map json) => Person( (k, e) => MapEntry(k as String, $enumDecode(_$CategoryEnumMap, e)), ) ..categoryCounts = (json['categoryCounts'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$CategoryEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$CategoryEnumMap, k), (e as num).toInt()), ); Map _$PersonToJson(Person instance) => { @@ -66,11 +67,11 @@ Order _$OrderFromJson(Map json) { (json['items'] as List?) ?.map((e) => Item.fromJson(Map.from(e as Map))), ) - ..count = json['count'] as int? + ..count = (json['count'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool? ..duration = json['duration'] == null ? null - : Duration(microseconds: json['duration'] as int) + : Duration(microseconds: (json['duration'] as num).toInt()) ..platform = json['platform'] == null ? null : Platform.fromJson(json['platform'] as String) @@ -113,13 +114,15 @@ const _$StatusCodeEnumMap = { }; Item _$ItemFromJson(Map json) => Item( - json['price'] as int?, + (json['price'] as num?)?.toInt(), ) - ..itemNumber = json['item-number'] as int? + ..itemNumber = (json['item-number'] as num?)?.toInt() ..saleDates = (json['saleDates'] as List?) ?.map((e) => DateTime.parse(e as String)) .toList() - ..rates = (json['rates'] as List?)?.map((e) => e as int).toList() + ..rates = (json['rates'] as List?) + ?.map((e) => (e as num).toInt()) + .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); Map _$ItemToJson(Item instance) { @@ -142,7 +145,8 @@ Map _$ItemToJson(Item instance) { } Numbers _$NumbersFromJson(Map json) => Numbers() - ..ints = (json['ints'] as List?)?.map((e) => e as int).toList() + ..ints = + (json['ints'] as List?)?.map((e) => (e as num).toInt()).toList() ..nums = (json['nums'] as List?)?.map((e) => e as num).toList() ..doubles = (json['doubles'] as List?) ?.map((e) => (e as num).toDouble()) @@ -150,8 +154,8 @@ Numbers _$NumbersFromJson(Map json) => Numbers() ..nnDoubles = (json['nnDoubles'] as List?) ?.map((e) => (e as num).toDouble()) .toList() - ..duration = durationFromInt(json['duration'] as int?) - ..date = dateTimeFromEpochUs(json['date'] as int?); + ..duration = durationFromInt((json['duration'] as num).toInt()) + ..date = dateTimeFromEpochUs((json['date'] as num).toInt()); Map _$NumbersToJson(Numbers instance) => { 'ints': instance.ints, @@ -164,16 +168,16 @@ Map _$NumbersToJson(Numbers instance) => { MapKeyVariety _$MapKeyVarietyFromJson(Map json) => MapKeyVariety() ..intIntMap = (json['intIntMap'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k as String), e as int), + (k, e) => MapEntry(int.parse(k as String), (e as num).toInt()), ) ..uriIntMap = (json['uriIntMap'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k as String), e as int), + (k, e) => MapEntry(Uri.parse(k as String), (e as num).toInt()), ) ..dateTimeIntMap = (json['dateTimeIntMap'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k as String), e as int), + (k, e) => MapEntry(DateTime.parse(k as String), (e as num).toInt()), ) ..bigIntMap = (json['bigIntMap'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k as String), e as int), + (k, e) => MapEntry(BigInt.parse(k as String), (e as num).toInt()), ); Map _$MapKeyVarietyToJson(MapKeyVariety instance) => @@ -202,7 +206,7 @@ UnknownEnumValue _$UnknownEnumValueFromJson(Map json) => UnknownEnumValue() PrivateConstructor _$PrivateConstructorFromJson(Map json) => PrivateConstructor._( - json['id'] as int, + (json['id'] as num).toInt(), json['value'] as String, ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart index d9230fbc5..25eb83164 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -158,9 +161,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num).toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => + const DurationMillisecondConverter().fromJson((e as num).toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -175,16 +180,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num).toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num).toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num).toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart index 74a348f5e..67faef581 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_any_map.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -77,11 +80,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..simpleObject = SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson(json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertAnyNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -149,9 +152,11 @@ $Rec? _$recordConvertAnyNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num).toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => + const DurationMillisecondConverter().fromJson((e as num).toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -166,16 +171,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num).toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num).toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num).toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart index d08da32c5..5fc193ddb 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart @@ -13,7 +13,8 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( json, ($checkedConvert) { final val = KitchenSink( - ctorValidatedNo42: $checkedConvert('no-42', (v) => v as int?), + ctorValidatedNo42: + $checkedConvert('no-42', (v) => (v as num?)?.toInt()), iterable: $checkedConvert( 'iterable', (v) => v as List?, @@ -24,7 +25,7 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( objectIterable: $checkedConvert('objectIterable', (v) => (v as List?)?.map((e) => e as Object)), intIterable: $checkedConvert('intIterable', - (v) => (v as List?)?.map((e) => e as int)), + (v) => (v as List?)?.map((e) => (e as num).toInt())), dateTimeIterable: $checkedConvert( 'datetime-iterable', (v) => (v as List?) @@ -45,8 +46,8 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( (v as List).map((e) => e as Object).toSet()); $checkedConvert( 'intSet', - (v) => - val.intSet = (v as List).map((e) => e as int).toSet()); + (v) => val.intSet = + (v as List).map((e) => (e as num).toInt()).toSet()); $checkedConvert( 'dateTimeSet', (v) => val.dateTimeSet = (v as List) @@ -62,7 +63,7 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( $checkedConvert( 'intList', (v) => val.intList = - (v as List).map((e) => e as int).toList()); + (v as List).map((e) => (e as num).toInt()).toList()); $checkedConvert( 'dateTimeList', (v) => val.dateTimeList = (v as List) @@ -120,13 +121,13 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( $checkedConvert('strictKeysObject', (v) => val.strictKeysObject = StrictKeysObject.fromJson(v as Map)); $checkedConvert('validatedPropertyNo42', - (v) => val.validatedPropertyNo42 = v as int?); + (v) => val.validatedPropertyNo42 = (v as num?)?.toInt()); $checkedConvert( 'recordField', (v) => val.recordField = _$recordConvertAnyNullable( v, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -206,13 +207,15 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => json, ($checkedConvert) { final val = JsonConverterTestClass( - $checkedConvert('duration', - (v) => const DurationMillisecondConverter().fromJson(v as int?)), + $checkedConvert( + 'duration', + (v) => const DurationMillisecondConverter() + .fromJson((v as num).toInt())), $checkedConvert( 'durationList', (v) => (v as List) - .map((e) => - const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num).toInt())) .toList()), $checkedConvert('bigInt', (v) => const BigIntStringConverter().fromJson(v as String)), @@ -234,25 +237,31 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), )), - $checkedConvert('numberSilly', - (v) => TrivialNumberConverter.instance.fromJson(v as int?)), + $checkedConvert( + 'numberSilly', + (v) => + TrivialNumberConverter.instance.fromJson((v as num).toInt())), $checkedConvert( 'numberSillySet', (v) => (v as List) - .map((e) => - TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => TrivialNumberConverter.instance + .fromJson((e as num).toInt())) .toSet()), - $checkedConvert('dateTime', - (v) => const EpochDateTimeConverter().fromJson(v as int?)), + $checkedConvert( + 'dateTime', + (v) => + const EpochDateTimeConverter().fromJson((v as num).toInt())), $checkedConvert('trivialString', (v) => trivialStringConverter.fromJson(v as String?)), - $checkedConvert('nullableNumberSilly', - (v) => TrivialNumberConverter.instance.fromJson(v as int?)), + $checkedConvert( + 'nullableNumberSilly', + (v) => + TrivialNumberConverter.instance.fromJson((v as num).toInt())), $checkedConvert( 'nullableNumberSillySet', (v) => (v as List) - .map((e) => - TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => TrivialNumberConverter.instance + .fromJson((e as num).toInt())) .toSet()), ); return val; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart index 76504317c..9e46d7c6e 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_exclude_null.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -168,9 +171,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num).toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => + const DurationMillisecondConverter().fromJson((e as num).toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -185,16 +190,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num).toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num).toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num).toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart index ff092269c..2dd79b555 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_explicit_to_json.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -160,9 +163,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num).toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => + const DurationMillisecondConverter().fromJson((e as num).toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -177,16 +182,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num).toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num).toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num).toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num).toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/simple_object.g.dart b/json_serializable/test/kitchen_sink/simple_object.g.dart index b0bbfbef0..53442bc1b 100644 --- a/json_serializable/test/kitchen_sink/simple_object.g.dart +++ b/json_serializable/test/kitchen_sink/simple_object.g.dart @@ -9,7 +9,7 @@ part of 'simple_object.dart'; // ************************************************************************** SimpleObject _$SimpleObjectFromJson(Map json) => SimpleObject( - json['value'] as int, + (json['value'] as num).toInt(), ); Map _$SimpleObjectToJson(SimpleObject instance) => diff --git a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart index b6b00cce3..820d237ee 100644 --- a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart +++ b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart @@ -15,7 +15,7 @@ StrictKeysObject _$StrictKeysObjectFromJson(Map json) { requiredKeys: const ['value', 'custom_field'], ); return StrictKeysObject( - json['value'] as int, + (json['value'] as num).toInt(), json['custom_field'] as String, ); } diff --git a/json_serializable/test/supported_types/input.type_duration.g.dart b/json_serializable/test/supported_types/input.type_duration.g.dart index 7ea4c7da6..9d57d843c 100644 --- a/json_serializable/test/supported_types/input.type_duration.g.dart +++ b/json_serializable/test/supported_types/input.type_duration.g.dart @@ -9,7 +9,7 @@ part of 'input.type_duration.dart'; // ************************************************************************** SimpleClass _$SimpleClassFromJson(Map json) => SimpleClass( - Duration(microseconds: json['value'] as int), + Duration(microseconds: (json['value'] as num).toInt()), ); Map _$SimpleClassToJson(SimpleClass instance) => @@ -21,7 +21,7 @@ SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => SimpleClassNullable( json['value'] == null ? null - : Duration(microseconds: json['value'] as int), + : Duration(microseconds: (json['value'] as num).toInt()), ); Map _$SimpleClassNullableToJson( diff --git a/json_serializable/test/supported_types/input.type_int.g.dart b/json_serializable/test/supported_types/input.type_int.g.dart index ddb06ed57..2f248b74a 100644 --- a/json_serializable/test/supported_types/input.type_int.g.dart +++ b/json_serializable/test/supported_types/input.type_int.g.dart @@ -9,8 +9,8 @@ part of 'input.type_int.dart'; // ************************************************************************** SimpleClass _$SimpleClassFromJson(Map json) => SimpleClass( - json['value'] as int, - json['withDefault'] as int? ?? 42, + (json['value'] as num).toInt(), + (json['withDefault'] as num?)?.toInt() ?? 42, ); Map _$SimpleClassToJson(SimpleClass instance) => @@ -21,8 +21,8 @@ Map _$SimpleClassToJson(SimpleClass instance) => SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => SimpleClassNullable( - json['value'] as int?, - json['withDefault'] as int? ?? 42, + (json['value'] as num?)?.toInt(), + (json['withDefault'] as num?)?.toInt() ?? 42, ); Map _$SimpleClassNullableToJson( diff --git a/json_serializable/test/supported_types/input.type_iterable.g.dart b/json_serializable/test/supported_types/input.type_iterable.g.dart index 95c3e0557..a9264f393 100644 --- a/json_serializable/test/supported_types/input.type_iterable.g.dart +++ b/json_serializable/test/supported_types/input.type_iterable.g.dart @@ -231,7 +231,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)), + .map((e) => Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassOfDurationToJson( @@ -244,7 +244,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)), + ?.map((e) => Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassNullableOfDurationToJson( @@ -256,8 +256,8 @@ Map _$SimpleClassNullableOfDurationToJson( SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( - (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)), + (json['value'] as List).map( + (e) => e == null ? null : Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassOfDurationNullableToJson( @@ -270,8 +270,8 @@ SimpleClassNullableOfDurationNullable _$SimpleClassNullableOfDurationNullableFromJson( Map json) => SimpleClassNullableOfDurationNullable( - (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)), + (json['value'] as List?)?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassNullableOfDurationNullableToJson( @@ -446,7 +446,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int), + (json['value'] as List).map((e) => (e as num).toInt()), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -457,7 +457,7 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int), + (json['value'] as List?)?.map((e) => (e as num).toInt()), ); Map _$SimpleClassNullableOfIntToJson( @@ -469,7 +469,7 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?), + (json['value'] as List).map((e) => (e as num?)?.toInt()), ); Map _$SimpleClassOfIntNullableToJson( @@ -481,7 +481,7 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?), + (json['value'] as List?)?.map((e) => (e as num?)?.toInt()), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -588,7 +588,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => (json['value'] as List).map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -619,7 +619,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( (json['value'] as List?)?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_list.g.dart b/json_serializable/test/supported_types/input.type_list.g.dart index 2f4497581..f86a6d00c 100644 --- a/json_serializable/test/supported_types/input.type_list.g.dart +++ b/json_serializable/test/supported_types/input.type_list.g.dart @@ -249,7 +249,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)) + .map((e) => Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -263,7 +263,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)) + ?.map((e) => Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -277,7 +277,8 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)) + .map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -292,7 +293,8 @@ SimpleClassNullableOfDurationNullable Map json) => SimpleClassNullableOfDurationNullable( (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)) + ?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -480,7 +482,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int).toList(), + (json['value'] as List).map((e) => (e as num).toInt()).toList(), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -491,7 +493,9 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int).toList(), + (json['value'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), ); Map _$SimpleClassNullableOfIntToJson( @@ -503,7 +507,9 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?).toList(), + (json['value'] as List) + .map((e) => (e as num?)?.toInt()) + .toList(), ); Map _$SimpleClassOfIntNullableToJson( @@ -515,7 +521,9 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?).toList(), + (json['value'] as List?) + ?.map((e) => (e as num?)?.toInt()) + .toList(), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -623,7 +631,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => .map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -656,7 +664,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( ?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_map.g.dart b/json_serializable/test/supported_types/input.type_map.g.dart index 5f29d60ab..5c8a3ea82 100644 --- a/json_serializable/test/supported_types/input.type_map.g.dart +++ b/json_serializable/test/supported_types/input.type_map.g.dart @@ -1953,7 +1953,8 @@ SimpleClassOfBigIntToDuration _$SimpleClassOfBigIntToDurationFromJson( Map json) => SimpleClassOfBigIntToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + BigInt.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -1969,8 +1970,8 @@ SimpleClassNullableOfBigIntToDuration Map json) => SimpleClassNullableOfBigIntToDuration( (json['value'] as Map?)?.map( - (k, e) => - MapEntry(BigInt.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + BigInt.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -1985,7 +1986,8 @@ SimpleClassOfDateTimeToDuration _$SimpleClassOfDateTimeToDurationFromJson( Map json) => SimpleClassOfDateTimeToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + DateTime.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2001,8 +2003,8 @@ SimpleClassNullableOfDateTimeToDuration Map json) => SimpleClassNullableOfDateTimeToDuration( (json['value'] as Map?)?.map( - (k, e) => - MapEntry(DateTime.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + DateTime.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2017,7 +2019,7 @@ SimpleClassOfDynamicToDuration _$SimpleClassOfDynamicToDurationFromJson( Map json) => SimpleClassOfDynamicToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2032,7 +2034,7 @@ SimpleClassNullableOfDynamicToDuration Map json) => SimpleClassNullableOfDynamicToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2047,7 +2049,7 @@ SimpleClassOfEnumTypeToDuration _$SimpleClassOfEnumTypeToDurationFromJson( SimpleClassOfEnumTypeToDuration( (json['value'] as Map).map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - Duration(microseconds: e as int)), + Duration(microseconds: (e as num).toInt())), ), ); @@ -2064,7 +2066,7 @@ SimpleClassNullableOfEnumTypeToDuration SimpleClassNullableOfEnumTypeToDuration( (json['value'] as Map?)?.map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - Duration(microseconds: e as int)), + Duration(microseconds: (e as num).toInt())), ), ); @@ -2079,7 +2081,8 @@ SimpleClassOfIntToDuration _$SimpleClassOfIntToDurationFromJson( Map json) => SimpleClassOfIntToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(int.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2094,7 +2097,8 @@ SimpleClassNullableOfIntToDuration _$SimpleClassNullableOfIntToDurationFromJson( Map json) => SimpleClassNullableOfIntToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(int.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2109,7 +2113,7 @@ SimpleClassOfObjectToDuration _$SimpleClassOfObjectToDurationFromJson( Map json) => SimpleClassOfObjectToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2124,7 +2128,7 @@ SimpleClassNullableOfObjectToDuration Map json) => SimpleClassNullableOfObjectToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2138,7 +2142,7 @@ SimpleClassOfStringToDuration _$SimpleClassOfStringToDurationFromJson( Map json) => SimpleClassOfStringToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2153,7 +2157,7 @@ SimpleClassNullableOfStringToDuration Map json) => SimpleClassNullableOfStringToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2167,7 +2171,8 @@ SimpleClassOfUriToDuration _$SimpleClassOfUriToDurationFromJson( Map json) => SimpleClassOfUriToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(Uri.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2182,7 +2187,8 @@ SimpleClassNullableOfUriToDuration _$SimpleClassNullableOfUriToDurationFromJson( Map json) => SimpleClassNullableOfUriToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(Uri.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2199,7 +2205,7 @@ SimpleClassOfBigIntToDurationNullable SimpleClassOfBigIntToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry(BigInt.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2216,7 +2222,7 @@ SimpleClassNullableOfBigIntToDurationNullable SimpleClassNullableOfBigIntToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(BigInt.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2233,7 +2239,7 @@ SimpleClassOfDateTimeToDurationNullable SimpleClassOfDateTimeToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry(DateTime.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2250,7 +2256,7 @@ SimpleClassNullableOfDateTimeToDurationNullable SimpleClassNullableOfDateTimeToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(DateTime.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2266,8 +2272,8 @@ SimpleClassOfDynamicToDurationNullable Map json) => SimpleClassOfDynamicToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2282,8 +2288,8 @@ SimpleClassNullableOfDynamicToDurationNullable Map json) => SimpleClassNullableOfDynamicToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2299,7 +2305,7 @@ SimpleClassOfEnumTypeToDurationNullable SimpleClassOfEnumTypeToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2316,7 +2322,7 @@ SimpleClassNullableOfEnumTypeToDurationNullable SimpleClassNullableOfEnumTypeToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2331,8 +2337,8 @@ SimpleClassOfIntToDurationNullable _$SimpleClassOfIntToDurationNullableFromJson( Map json) => SimpleClassOfIntToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - int.parse(k), e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(int.parse(k), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2349,7 +2355,7 @@ SimpleClassNullableOfIntToDurationNullable SimpleClassNullableOfIntToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(int.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2365,8 +2371,8 @@ SimpleClassOfObjectToDurationNullable Map json) => SimpleClassOfObjectToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2381,8 +2387,8 @@ SimpleClassNullableOfObjectToDurationNullable Map json) => SimpleClassNullableOfObjectToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2397,8 +2403,8 @@ SimpleClassOfStringToDurationNullable Map json) => SimpleClassOfStringToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2413,8 +2419,8 @@ SimpleClassNullableOfStringToDurationNullable Map json) => SimpleClassNullableOfStringToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2428,8 +2434,8 @@ SimpleClassOfUriToDurationNullable _$SimpleClassOfUriToDurationNullableFromJson( Map json) => SimpleClassOfUriToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - Uri.parse(k), e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(Uri.parse(k), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2446,7 +2452,7 @@ SimpleClassNullableOfUriToDurationNullable SimpleClassNullableOfUriToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(Uri.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -3943,7 +3949,7 @@ SimpleClassOfBigIntToInt _$SimpleClassOfBigIntToIntFromJson( Map json) => SimpleClassOfBigIntToInt( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ), ); @@ -3957,7 +3963,7 @@ SimpleClassNullableOfBigIntToInt _$SimpleClassNullableOfBigIntToIntFromJson( Map json) => SimpleClassNullableOfBigIntToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ), ); @@ -3971,7 +3977,7 @@ SimpleClassOfDateTimeToInt _$SimpleClassOfDateTimeToIntFromJson( Map json) => SimpleClassOfDateTimeToInt( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ), ); @@ -3985,7 +3991,7 @@ SimpleClassNullableOfDateTimeToInt _$SimpleClassNullableOfDateTimeToIntFromJson( Map json) => SimpleClassNullableOfDateTimeToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ), ); @@ -4011,7 +4017,7 @@ SimpleClassNullableOfDynamicToInt _$SimpleClassNullableOfDynamicToIntFromJson( Map json) => SimpleClassNullableOfDynamicToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4025,7 +4031,8 @@ SimpleClassOfEnumTypeToInt _$SimpleClassOfEnumTypeToIntFromJson( Map json) => SimpleClassOfEnumTypeToInt( (json['value'] as Map).map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num).toInt()), ), ); @@ -4039,7 +4046,8 @@ SimpleClassNullableOfEnumTypeToInt _$SimpleClassNullableOfEnumTypeToIntFromJson( Map json) => SimpleClassNullableOfEnumTypeToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num).toInt()), ), ); @@ -4054,7 +4062,7 @@ SimpleClassOfIntToInt _$SimpleClassOfIntToIntFromJson( Map json) => SimpleClassOfIntToInt( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ), ); @@ -4068,7 +4076,7 @@ SimpleClassNullableOfIntToInt _$SimpleClassNullableOfIntToIntFromJson( Map json) => SimpleClassNullableOfIntToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ), ); @@ -4094,7 +4102,7 @@ SimpleClassNullableOfObjectToInt _$SimpleClassNullableOfObjectToIntFromJson( Map json) => SimpleClassNullableOfObjectToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4120,7 +4128,7 @@ SimpleClassNullableOfStringToInt _$SimpleClassNullableOfStringToIntFromJson( Map json) => SimpleClassNullableOfStringToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4134,7 +4142,7 @@ SimpleClassOfUriToInt _$SimpleClassOfUriToIntFromJson( Map json) => SimpleClassOfUriToInt( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ), ); @@ -4148,7 +4156,7 @@ SimpleClassNullableOfUriToInt _$SimpleClassNullableOfUriToIntFromJson( Map json) => SimpleClassNullableOfUriToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ), ); @@ -4162,7 +4170,7 @@ SimpleClassOfBigIntToIntNullable _$SimpleClassOfBigIntToIntNullableFromJson( Map json) => SimpleClassOfBigIntToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), e as int?), + (k, e) => MapEntry(BigInt.parse(k), (e as num?)?.toInt()), ), ); @@ -4177,7 +4185,7 @@ SimpleClassNullableOfBigIntToIntNullable Map json) => SimpleClassNullableOfBigIntToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int?), + (k, e) => MapEntry(BigInt.parse(k), (e as num?)?.toInt()), ), ); @@ -4191,7 +4199,7 @@ SimpleClassOfDateTimeToIntNullable _$SimpleClassOfDateTimeToIntNullableFromJson( Map json) => SimpleClassOfDateTimeToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), e as int?), + (k, e) => MapEntry(DateTime.parse(k), (e as num?)?.toInt()), ), ); @@ -4206,7 +4214,7 @@ SimpleClassNullableOfDateTimeToIntNullable Map json) => SimpleClassNullableOfDateTimeToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int?), + (k, e) => MapEntry(DateTime.parse(k), (e as num?)?.toInt()), ), ); @@ -4233,7 +4241,7 @@ SimpleClassNullableOfDynamicToIntNullable Map json) => SimpleClassNullableOfDynamicToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4247,7 +4255,8 @@ SimpleClassOfEnumTypeToIntNullable _$SimpleClassOfEnumTypeToIntNullableFromJson( Map json) => SimpleClassOfEnumTypeToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int?), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num?)?.toInt()), ), ); @@ -4262,7 +4271,8 @@ SimpleClassNullableOfEnumTypeToIntNullable Map json) => SimpleClassNullableOfEnumTypeToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int?), + (k, e) => MapEntry( + $enumDecode(_$EnumTypeEnumMap, k), (e as num?)?.toInt()), ), ); @@ -4277,7 +4287,7 @@ SimpleClassOfIntToIntNullable _$SimpleClassOfIntToIntNullableFromJson( Map json) => SimpleClassOfIntToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), e as int?), + (k, e) => MapEntry(int.parse(k), (e as num?)?.toInt()), ), ); @@ -4292,7 +4302,7 @@ SimpleClassNullableOfIntToIntNullable Map json) => SimpleClassNullableOfIntToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int?), + (k, e) => MapEntry(int.parse(k), (e as num?)?.toInt()), ), ); @@ -4319,7 +4329,7 @@ SimpleClassNullableOfObjectToIntNullable Map json) => SimpleClassNullableOfObjectToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4346,7 +4356,7 @@ SimpleClassNullableOfStringToIntNullable Map json) => SimpleClassNullableOfStringToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4360,7 +4370,7 @@ SimpleClassOfUriToIntNullable _$SimpleClassOfUriToIntNullableFromJson( Map json) => SimpleClassOfUriToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), e as int?), + (k, e) => MapEntry(Uri.parse(k), (e as num?)?.toInt()), ), ); @@ -4375,7 +4385,7 @@ SimpleClassNullableOfUriToIntNullable Map json) => SimpleClassNullableOfUriToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int?), + (k, e) => MapEntry(Uri.parse(k), (e as num?)?.toInt()), ), ); @@ -5290,7 +5300,7 @@ SimpleClassOfBigIntToRecord _$SimpleClassOfBigIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5324,7 +5334,7 @@ SimpleClassNullableOfBigIntToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5352,7 +5362,7 @@ SimpleClassOfDateTimeToRecord _$SimpleClassOfDateTimeToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5381,7 +5391,7 @@ SimpleClassNullableOfDateTimeToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5409,7 +5419,7 @@ SimpleClassOfDynamicToRecord _$SimpleClassOfDynamicToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5436,7 +5446,7 @@ SimpleClassNullableOfDynamicToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5463,7 +5473,7 @@ SimpleClassOfEnumTypeToRecord _$SimpleClassOfEnumTypeToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5492,7 +5502,7 @@ SimpleClassNullableOfEnumTypeToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5520,7 +5530,7 @@ SimpleClassOfIntToRecord _$SimpleClassOfIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5548,7 +5558,7 @@ SimpleClassNullableOfIntToRecord _$SimpleClassNullableOfIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5576,7 +5586,7 @@ SimpleClassOfObjectToRecord _$SimpleClassOfObjectToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5603,7 +5613,7 @@ SimpleClassNullableOfObjectToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5630,7 +5640,7 @@ SimpleClassOfStringToRecord _$SimpleClassOfStringToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5657,7 +5667,7 @@ SimpleClassNullableOfStringToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5684,7 +5694,7 @@ SimpleClassOfUriToRecord _$SimpleClassOfUriToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5712,7 +5722,7 @@ SimpleClassNullableOfUriToRecord _$SimpleClassNullableOfUriToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_record.g.dart b/json_serializable/test/supported_types/input.type_record.g.dart index 5c96d58c8..bc37b7cd2 100644 --- a/json_serializable/test/supported_types/input.type_record.g.dart +++ b/json_serializable/test/supported_types/input.type_record.g.dart @@ -411,8 +411,8 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( _$recordConvert( json['value'], ($jsonValue) => ( - Duration(microseconds: $jsonValue[r'$1'] as int), - named: Duration(microseconds: $jsonValue['named'] as int), + Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), + named: Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -432,8 +432,8 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - Duration(microseconds: $jsonValue[r'$1'] as int), - named: Duration(microseconds: $jsonValue['named'] as int), + Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), + named: Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -457,10 +457,10 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( ($jsonValue) => ( $jsonValue[r'$1'] == null ? null - : Duration(microseconds: $jsonValue[r'$1'] as int), + : Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), named: $jsonValue['named'] == null ? null - : Duration(microseconds: $jsonValue['named'] as int), + : Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -483,10 +483,11 @@ SimpleClassNullableOfDurationNullable ($jsonValue) => ( $jsonValue[r'$1'] == null ? null - : Duration(microseconds: $jsonValue[r'$1'] as int), + : Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), named: $jsonValue['named'] == null ? null - : Duration(microseconds: $jsonValue['named'] as int), + : Duration( + microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -785,8 +786,8 @@ SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => _$recordConvert( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, - named: $jsonValue['named'] as int, + ($jsonValue[r'$1'] as num).toInt(), + named: ($jsonValue['named'] as num).toInt(), ), ), ); @@ -805,8 +806,8 @@ SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, - named: $jsonValue['named'] as int, + ($jsonValue[r'$1'] as num).toInt(), + named: ($jsonValue['named'] as num).toInt(), ), ), ); @@ -828,8 +829,8 @@ SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( _$recordConvert( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int?, - named: $jsonValue['named'] as int?, + ($jsonValue[r'$1'] as num?)?.toInt(), + named: ($jsonValue['named'] as num?)?.toInt(), ), ), ); @@ -849,8 +850,8 @@ SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int?, - named: $jsonValue['named'] as int?, + ($jsonValue[r'$1'] as num?)?.toInt(), + named: ($jsonValue['named'] as num?)?.toInt(), ), ), ); @@ -1047,7 +1048,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => _$recordConvert( $jsonValue[r'$1'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1055,7 +1056,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => named: _$recordConvert( $jsonValue['named'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1090,7 +1091,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( _$recordConvert( $jsonValue[r'$1'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1098,7 +1099,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( named: _$recordConvert( $jsonValue['named'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_set.g.dart b/json_serializable/test/supported_types/input.type_set.g.dart index 73866adf9..234afad93 100644 --- a/json_serializable/test/supported_types/input.type_set.g.dart +++ b/json_serializable/test/supported_types/input.type_set.g.dart @@ -251,7 +251,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)) + .map((e) => Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -265,7 +265,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)) + ?.map((e) => Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -279,7 +279,8 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)) + .map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -294,7 +295,8 @@ SimpleClassNullableOfDurationNullable Map json) => SimpleClassNullableOfDurationNullable( (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)) + ?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -482,7 +484,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int).toSet(), + (json['value'] as List).map((e) => (e as num).toInt()).toSet(), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -493,7 +495,7 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int).toSet(), + (json['value'] as List?)?.map((e) => (e as num).toInt()).toSet(), ); Map _$SimpleClassNullableOfIntToJson( @@ -505,7 +507,7 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?).toSet(), + (json['value'] as List).map((e) => (e as num?)?.toInt()).toSet(), ); Map _$SimpleClassOfIntNullableToJson( @@ -517,7 +519,9 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?).toSet(), + (json['value'] as List?) + ?.map((e) => (e as num?)?.toInt()) + .toSet(), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -625,7 +629,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => .map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -658,7 +662,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( ?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/tool/readme/readme_examples.g.dart b/json_serializable/tool/readme/readme_examples.g.dart index c22e9025b..b3a60ab36 100644 --- a/json_serializable/tool/readme/readme_examples.g.dart +++ b/json_serializable/tool/readme/readme_examples.g.dart @@ -9,7 +9,7 @@ part of 'readme_examples.dart'; // ************************************************************************** Sample1 _$Sample1FromJson(Map json) => Sample1( - Sample2.fromJson(json['value'] as int), + Sample2.fromJson((json['value'] as num).toInt()), ); Map _$Sample1ToJson(Sample1 instance) => { @@ -17,7 +17,7 @@ Map _$Sample1ToJson(Sample1 instance) => { }; Sample3 _$Sample3FromJson(Map json) => Sample3( - Sample3._fromJson(json['value'] as int), + Sample3._fromJson((json['value'] as num).toInt()), ); Map _$Sample3ToJson(Sample3 instance) => { @@ -25,7 +25,7 @@ Map _$Sample3ToJson(Sample3 instance) => { }; Sample4 _$Sample4FromJson(Map json) => Sample4( - const EpochDateTimeConverter().fromJson(json['value'] as int), + const EpochDateTimeConverter().fromJson((json['value'] as num).toInt()), ); Map _$Sample4ToJson(Sample4 instance) => {