From 49cd5619e613b1cc96081af232b041fd483ab8e4 Mon Sep 17 00:00:00 2001 From: pmg1991 <34839986+pmg1991@users.noreply.github.com> Date: Sat, 27 Apr 2024 20:27:44 +0530 Subject: [PATCH] Update class.mustache --- .../resources/dart2-v3template/class.mustache | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/resources/dart2-v3template/class.mustache b/src/main/resources/dart2-v3template/class.mustache index e2b24c9..5741223 100644 --- a/src/main/resources/dart2-v3template/class.mustache +++ b/src/main/resources/dart2-v3template/class.mustache @@ -85,19 +85,21 @@ class {{{classname}}}{{#parent}} extends {{parent}}{{/parent}} { {{^vendorExtensions.x-var-is-binary}} {{^isNullable}} final _jsonData = json[r'{{{baseName}}}']; - if (_jsonData == null) { - {{#required}} - {{#defaultValue}} return {{{defaultValue}}};{{/defaultValue}} - {{^defaultValue}}{{> _deserialisation_error }}{{/defaultValue}} - {{/required}} - {{^required}} - {{#defaultValue}} return {{{defaultValue}}};{{/defaultValue}} - {{^defaultValue}}{{> _deserialisation_error }}{{/defaultValue}} - {{/required}} - } + {{#defaultValue}} + if (_jsonData == null) { + return {{{defaultValue}}}; + } + {{/defaultValue}} {{#isArray}}{{>_complex_from_json_required}}{{/isArray}} {{#isMap}}{{>_complex_from_json_required}}{{/isMap}} - {{^items}}{{>_simple_from_json_required}}{{/items}} + {{^items}} + {{^defaultValue}} + if (_jsonData == null) { + {{> _deserialisation_error }} + } + {{/defaultValue}} + {{>_simple_from_json_required}} + {{/items}} {{/isNullable}} {{#isNullable}}