diff --git a/angel_serialize_generator/CHANGELOG.md b/angel_serialize_generator/CHANGELOG.md index 03798661..ab2bd968 100644 --- a/angel_serialize_generator/CHANGELOG.md +++ b/angel_serialize_generator/CHANGELOG.md @@ -4,6 +4,7 @@ * Support pulling fields from parent classes and interfaces. * Only generate `const` constructors if *all* fields lack a setter. +* Don't type-annotate initializing formals. # 2.4.4 * Remove unnecessary `new` and `const`. diff --git a/angel_serialize_generator/lib/model.dart b/angel_serialize_generator/lib/model.dart index 01d5ec16..55691d78 100644 --- a/angel_serialize_generator/lib/model.dart +++ b/angel_serialize_generator/lib/model.dart @@ -141,7 +141,7 @@ class JsonModelGenerator extends GeneratorForAnnotation { if (!isListOrMapType(field.type)) { b.toThis = true; - } else { + } else if (!b.toThis) { b.type = convertTypeReference(field.type); } diff --git a/angel_serialize_generator/test/models/goat.g.dart b/angel_serialize_generator/test/models/goat.g.dart index 0c0659e0..a58ddcda 100644 --- a/angel_serialize_generator/test/models/goat.g.dart +++ b/angel_serialize_generator/test/models/goat.g.dart @@ -8,7 +8,7 @@ part of 'goat.dart'; @generatedSerializable class Goat implements _Goat { - const Goat({this.integer = 34, List this.list = const [34, 35]}); + const Goat({this.integer = 34, this.list = const [34, 35]}); @override final int integer; diff --git a/angel_serialize_generator/test/models/has_map.g.dart b/angel_serialize_generator/test/models/has_map.g.dart index d3adbddd..300730c7 100644 --- a/angel_serialize_generator/test/models/has_map.g.dart +++ b/angel_serialize_generator/test/models/has_map.g.dart @@ -8,7 +8,7 @@ part of 'has_map.dart'; @generatedSerializable class HasMap implements _HasMap { - const HasMap({@required Map this.value}); + const HasMap({@required this.value}); @override final Map value; diff --git a/angel_serialize_generator/test/models/with_enum.g.dart b/angel_serialize_generator/test/models/with_enum.g.dart index 59c63ddc..13c21eb5 100644 --- a/angel_serialize_generator/test/models/with_enum.g.dart +++ b/angel_serialize_generator/test/models/with_enum.g.dart @@ -8,8 +8,7 @@ part of 'with_enum.dart'; @generatedSerializable class WithEnum implements _WithEnum { - const WithEnum( - {this.type = WithEnumType.b, List this.finalList, this.imageBytes}); + const WithEnum({this.type = WithEnumType.b, this.finalList, this.imageBytes}); @override final WithEnumType type;