Updated serialize generator
This commit is contained in:
parent
d5c625d9f9
commit
1bd40f28b4
1 changed files with 5 additions and 1 deletions
|
@ -72,11 +72,13 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
||||||
clazz.constructors.add(Constructor((b) => b..constant = true));
|
clazz.constructors.add(Constructor((b) => b..constant = true));
|
||||||
clazz.methods.add(Method((b) => b
|
clazz.methods.add(Method((b) => b
|
||||||
..name = 'encoder'
|
..name = 'encoder'
|
||||||
|
..returns = refer('${pascal}Encoder')
|
||||||
..type = MethodType.getter
|
..type = MethodType.getter
|
||||||
..annotations.add(refer('override'))
|
..annotations.add(refer('override'))
|
||||||
..body = refer('${pascal}Encoder').constInstance([]).code));
|
..body = refer('${pascal}Encoder').constInstance([]).code));
|
||||||
clazz.methods.add(Method((b) => b
|
clazz.methods.add(Method((b) => b
|
||||||
..name = 'decoder'
|
..name = 'decoder'
|
||||||
|
..returns = refer('${pascal}Decoder')
|
||||||
..type = MethodType.getter
|
..type = MethodType.getter
|
||||||
..annotations.add(refer('override'))
|
..annotations.add(refer('override'))
|
||||||
..body = refer('${pascal}Decoder').constInstance([]).code));
|
..body = refer('${pascal}Decoder').constInstance([]).code));
|
||||||
|
@ -110,6 +112,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
||||||
|
|
||||||
var buf = StringBuffer();
|
var buf = StringBuffer();
|
||||||
|
|
||||||
|
/*
|
||||||
ctx.requiredFields.forEach((key, msg) {
|
ctx.requiredFields.forEach((key, msg) {
|
||||||
if (ctx.excluded[key]?.canSerialize == false) return;
|
if (ctx.excluded[key]?.canSerialize == false) return;
|
||||||
buf.writeln('''
|
buf.writeln('''
|
||||||
|
@ -118,6 +121,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
||||||
}
|
}
|
||||||
''');
|
''');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
buf.writeln('return {');
|
buf.writeln('return {');
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
@ -198,7 +202,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
||||||
|
|
||||||
buf.write('};');
|
buf.write('};');
|
||||||
method.body = Block.of([
|
method.body = Block.of([
|
||||||
Code('if (model == null) { return null; }'),
|
// Code('if (model == null) { return null; }'),
|
||||||
Code(buf.toString()),
|
Code(buf.toString()),
|
||||||
]);
|
]);
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue