Skip to content

Commit

Permalink
Merge pull request #1020 from appwrite/fix-cast-string-arrays
Browse files Browse the repository at this point in the history
fix: cast string arrays
  • Loading branch information
christyjacob4 authored Dec 30, 2024
2 parents de6ac72 + 5d4e932 commit 6ff4678
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions templates/dart/lib/src/models/model.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
{{property.sub_schema | caseUcfirst | overrideIdentifier}}.fromMap(map['{{property.name | escapeDollarSign }}'])
{%- endif -%}
{%- else -%}
map['{{property.name | escapeDollarSign }}']
{%- if property.type == "number" -%}
{%- if not property.required %}?{% endif %}.toDouble()
{%- endif -%}
{%- if property.type == "string" -%}
{%- if not property.required %}?{% endif %}.toString()
{%- endif -%}
{%- if property.type == "array" -%}
{% if property.required %} ?? []{% endif %}
{%- if property.type == 'array' -%}
List<{{ property.items.type | caseUcfirst }}>.from(map['{{property.name | escapeDollarSign }}']?.map((x) => x{% if property.items.type == "string" %}.toString(){% endif %}) ?? [])
{%- else -%}
map['{{property.name | escapeDollarSign }}']
{%- if property.type == "number" -%}
{%- if not property.required %}?{% endif %}.toDouble()
{%- endif -%}
{%- if property.type == "string" -%}
{%- if not property.required %}?{% endif %}.toString()
{%- endif -%}
{%- endif -%}
{%- endif -%},
{% endfor %}
Expand Down Expand Up @@ -75,4 +76,4 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
{% endfor %}
{% endif %}
{% endfor %}
}
}

0 comments on commit 6ff4678

Please sign in to comment.