Remove defaults
This commit is contained in:
parent
c6f0ec4c71
commit
79ca9a6945
6 changed files with 26 additions and 17 deletions
|
@ -1,3 +1,12 @@
|
|||
# 2.0.9+4
|
||||
* Remove `defaults` in `build.yaml`.
|
||||
|
||||
# 2.0.9+3
|
||||
* Fix a cast error when self-referencing nested list expressions.
|
||||
|
||||
# 2.0.9+2
|
||||
* Fix previously unseen cast errors with enums.
|
||||
|
||||
# 2.0.9+1
|
||||
* Fix a cast error when deserializing nested model classes.
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@ builders:
|
|||
- ".d.ts"
|
||||
required_inputs:
|
||||
- .dart
|
||||
defaults:
|
||||
generate_for:
|
||||
- "lib/src/models/**.dart"
|
||||
- "test/**.dart"
|
||||
targets:
|
||||
_book:
|
||||
sources:
|
||||
|
|
|
@ -110,15 +110,17 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
var t = field.type as InterfaceType;
|
||||
|
||||
if (isListModelType(t)) {
|
||||
var rc = new ReCase(t.typeArguments[0].name);
|
||||
serializedRepresentation = 'model.${field.name}?.map(${rc
|
||||
.pascalCase}Serializer.toMap)?.toList()';
|
||||
//var rc = new ReCase(t.typeArguments[0].name);
|
||||
serializedRepresentation = '''
|
||||
model.${field.name}
|
||||
?.map((m) => m.toJson())
|
||||
?.toList()''';
|
||||
} else if (isMapToModelType(t)) {
|
||||
var rc = new ReCase(t.typeArguments[1].name);
|
||||
serializedRepresentation =
|
||||
'''model.${field.name}.keys?.fold({}, (map, key) {
|
||||
return map..[key] = ${serializerToMap(
|
||||
rc, 'model.${field.name}[key]')};
|
||||
return map..[key] =
|
||||
${serializerToMap(rc, 'model.${field.name}[key]')};
|
||||
})''';
|
||||
} else if (t.element.isEnum) {
|
||||
serializedRepresentation = '''
|
||||
|
@ -202,7 +204,7 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
else if (isModelClass(field.type)) {
|
||||
var rc = new ReCase(field.type.name);
|
||||
deserializedRepresentation = "map['$alias'] != null"
|
||||
" ? ${rc.pascalCase}Serializer.fromMap(map['$alias'])"
|
||||
" ? ${rc.pascalCase}Serializer.fromMap(map['$alias'] as Map)"
|
||||
" : null";
|
||||
} else if (field.type is InterfaceType) {
|
||||
var t = field.type as InterfaceType;
|
||||
|
@ -227,11 +229,11 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
} else if (t.element.isEnum) {
|
||||
deserializedRepresentation = '''
|
||||
map['$alias'] is ${t.name}
|
||||
? map['$alias']
|
||||
? (map['$alias'] as ${t.name})
|
||||
:
|
||||
(
|
||||
map['$alias'] is int
|
||||
? ${t.name}.values[map['$alias']]
|
||||
? ${t.name}.values[map['$alias'] as int]
|
||||
: null
|
||||
)
|
||||
''';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_serialize_generator
|
||||
version: 2.0.9+1
|
||||
version: 2.0.9+3
|
||||
description: Model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/serialize
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class AuthorSerializer {
|
|||
.map(BookSerializer.fromMap))
|
||||
: null,
|
||||
newestBook: map['newest_book'] != null
|
||||
? BookSerializer.fromMap(map['newest_book'])
|
||||
? BookSerializer.fromMap(map['newest_book'] as Map)
|
||||
: null,
|
||||
obscured: map['obscured'] as String,
|
||||
createdAt: map['created_at'] != null
|
||||
|
@ -57,7 +57,7 @@ abstract class AuthorSerializer {
|
|||
'id': model.id,
|
||||
'name': model.name,
|
||||
'age': model.age,
|
||||
'books': model.books?.map(BookSerializer.toMap)?.toList(),
|
||||
'books': model.books?.map((m) => m.toJson())?.toList(),
|
||||
'newest_book': BookSerializer.toMap(model.newestBook),
|
||||
'created_at': model.createdAt?.toIso8601String(),
|
||||
'updated_at': model.updatedAt?.toIso8601String()
|
||||
|
|
|
@ -10,8 +10,10 @@ abstract class WithEnumSerializer {
|
|||
static WithEnum fromMap(Map map) {
|
||||
return new WithEnum(
|
||||
type: map['type'] is WithEnumType
|
||||
? map['type']
|
||||
: (map['type'] is int ? WithEnumType.values[map['type']] : null),
|
||||
? (map['type'] as WithEnumType)
|
||||
: (map['type'] is int
|
||||
? WithEnumType.values[map['type'] as int]
|
||||
: null),
|
||||
finalList: map['final_list'] as List<int>);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue