Skip to content

Commit 6ff4678

Browse files
Merge pull request #1020 from appwrite/fix-cast-string-arrays
fix: cast string arrays
2 parents de6ac72 + 5d4e932 commit 6ff4678

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ 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 -%}
42-
{%- if property.type == "array" -%}
43-
{% if property.required %} ?? []{% endif %}
35+
{%- if property.type == 'array' -%}
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()
44+
{%- endif -%}
4445
{%- endif -%}
4546
{%- endif -%},
4647
{% endfor %}
@@ -75,4 +76,4 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
7576
{% endfor %}
7677
{% endif %}
7778
{% endfor %}
78-
}
79+
}

0 commit comments

Comments
 (0)