diff --git a/templates/dart/lib/src/models/model.dart.twig b/templates/dart/lib/src/models/model.dart.twig index 3ce581e20..33c81d923 100644 --- a/templates/dart/lib/src/models/model.dart.twig +++ b/templates/dart/lib/src/models/model.dart.twig @@ -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 %} @@ -75,4 +76,4 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model {% endfor %} {% endif %} {% endfor %} -} +} \ No newline at end of file