2023-09-05 01:08:43 +02:00
|
|
|
--- native_class.mustache 2023-08-31 23:09:59.584269162 +0200
|
|
|
|
+++ native_class1.mustache 2023-08-31 22:59:53.633083270 +0200
|
2023-01-10 06:08:45 +02:00
|
|
|
@@ -91,14 +91,14 @@
|
|
|
|
{{/isDateTime}}
|
|
|
|
{{#isNullable}}
|
|
|
|
} else {
|
|
|
|
- json[r'{{{baseName}}}'] = null;
|
2023-06-22 20:00:07 +02:00
|
|
|
+ // json[r'{{{baseName}}}'] = null;
|
2023-01-10 06:08:45 +02:00
|
|
|
}
|
|
|
|
{{/isNullable}}
|
|
|
|
{{^isNullable}}
|
|
|
|
{{^required}}
|
|
|
|
{{^defaultValue}}
|
|
|
|
} else {
|
|
|
|
- json[r'{{{baseName}}}'] = null;
|
2023-06-22 20:00:07 +02:00
|
|
|
+ // json[r'{{{baseName}}}'] = null;
|
2023-01-10 06:08:45 +02:00
|
|
|
}
|
|
|
|
{{/defaultValue}}
|
|
|
|
{{/required}}
|
2023-06-22 20:00:07 +02:00
|
|
|
@@ -114,17 +114,6 @@
|
|
|
|
if (value is Map) {
|
|
|
|
final json = value.cast<String, dynamic>();
|
|
|
|
|
|
|
|
- // Ensure that the map contains the required keys.
|
|
|
|
- // Note 1: the values aren't checked for validity beyond being non-null.
|
|
|
|
- // Note 2: this code is stripped in release mode!
|
|
|
|
- assert(() {
|
|
|
|
- requiredKeys.forEach((key) {
|
|
|
|
- assert(json.containsKey(key), 'Required key "{{{classname}}}[$key]" is missing from JSON.');
|
2023-06-22 19:48:57 +02:00
|
|
|
- assert(json[key] != null, 'Required key "{{{classname}}}[$key]" has a null value in JSON.');
|
2023-06-22 20:00:07 +02:00
|
|
|
- });
|
|
|
|
- return true;
|
|
|
|
- }());
|
|
|
|
-
|
|
|
|
return {{{classname}}}(
|
|
|
|
{{#vars}}
|
|
|
|
{{#isDateTime}}
|
2023-09-05 01:08:43 +02:00
|
|
|
@@ -215,6 +204,10 @@
|
|
|
|
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
|
|
|
: {{{datatypeWithEnum}}}.parse(json[r'{{{baseName}}}'].toString()),
|
|
|
|
{{/isNumber}}
|
|
|
|
+ {{#isDouble}}
|
|
|
|
+ {{{name}}}: (mapValueOfType<num>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(),
|
|
|
|
+ {{/isDouble}}
|
|
|
|
+ {{^isDouble}}
|
|
|
|
{{^isNumber}}
|
|
|
|
{{^isEnum}}
|
|
|
|
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
|
|
|
@@ -223,6 +216,7 @@
|
|
|
|
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
|
|
|
{{/isEnum}}
|
|
|
|
{{/isNumber}}
|
|
|
|
+ {{/isDouble}}
|
|
|
|
{{/isMap}}
|
|
|
|
{{/isArray}}
|
|
|
|
{{/complexType}}
|