toDart method
Final convert to Dart entitiy
Implementation
String toDart() {
return """class $name {
${fields.map((e) => ' ${e.type}? ${e.name};').join('\n')}
$name({${fields.where((e) => !e.name.startsWith("_")).map((e) => 'this.${e.name}').join(', ')}});
$name.parse(Map<String, dynamic> data) {
${fields.map((e) {
if (e.type.startsWith("List")) {
return " ${e.name} = (data['${e.name}'] as Iterable).map((dynamic e) => ${e.type.split("<")[1].split(">")[0]}.parse(e)).toList();";
} else if (e.type == "DateTime") {
return " ${e.name} = DateTime.parse(data['${e.name}']);";
} else {
return " ${e.name} = data['${e.name}'];";
}
}).join('\n')}
}
}""";
}