Skip to content

Commit 5d4e932

Browse files
committed
fix: template
1 parent 434c31a commit 5d4e932

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

templates/dart/lib/src/models/model.dart.twig

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
3232
{{property.sub_schema | caseUcfirst | overrideIdentifier}}.fromMap(map['{{property.name | escapeDollarSign }}'])
3333
{%- endif -%}
3434
{%- else -%}
35-
map['{{property.name | escapeDollarSign }}']
36-
{%- if property.type == "number" -%}
37-
{%- if not property.required %}?{% endif %}.toDouble()
38-
{%- endif -%}
39-
{%- if property.type == "string" -%}
40-
{%- if not property.required %}?{% endif %}.toString()
41-
{%- endif -%}
4235
{%- if property.type == 'array' -%}
43-
{%- if property.sub_schema -%}
44-
List<{{property.sub_schema | caseUcfirst | overrideIdentifier}}>.from(map['{{property.name | escapeDollarSign }}'].map((p) => {{property.sub_schema | caseUcfirst | overrideIdentifier}}.fromMap(p)))
45-
{%- else -%}
46-
List<{{ property | typeNameInner }}>.from(map['{{property.name | escapeDollarSign }}']?.map((x) => x{% if property.items.type == "string" %}.toString(){% endif %}) ?? [])
36+
List<{{ property.items.type | caseUcfirst }}>.from(map['{{property.name | escapeDollarSign }}']?.map((x) => x{% if property.items.type == "string" %}.toString(){% endif %}) ?? [])
37+
{%- else -%}
38+
map['{{property.name | escapeDollarSign }}']
39+
{%- if property.type == "number" -%}
40+
{%- if not property.required %}?{% endif %}.toDouble()
41+
{%- endif -%}
42+
{%- if property.type == "string" -%}
43+
{%- if not property.required %}?{% endif %}.toString()
4744
{%- endif -%}
4845
{%- endif -%}
4946
{%- endif -%},
@@ -79,4 +76,4 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
7976
{% endfor %}
8077
{% endif %}
8178
{% endfor %}
82-
}
79+
}

0 commit comments

Comments
 (0)