List<String> langList = [English, Gujarati, Hindi, Marathi, Punjabi, Urdu, Spanish]
var selectedLanguagesList = <LanguageDatum>[].obs;
langList is a string type of list. and selectedLanguagesList is a model type of list. How do I convert string list to model list in flutter ?
class LanguageDatum {
LanguageDatum({
this.id,
this.name,
this.status,
this.createdAt,
this.updatedAt,
this.deletedAt,
});
int? id;
String? name;
int? status;
DateTime? createdAt;
DateTime? updatedAt;
dynamic deletedAt;
factory LanguageDatum.fromJson(Map<String, dynamic> json) => LanguageDatum(
id: json["id"]??0,
name: json["name"]??"",
status: json["status"]??"",
createdAt: json["created_at"] != null ? DateTime.parse(json["created_at"]) : null,
updatedAt: json["updated_at"] != null ? DateTime.parse(json["updated_at"]) : null,
deletedAt: json["deleted_at"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"status": status,
"created_at": createdAt,
"updated_at": updatedAt,
"deleted_at": deletedAt,
};
}
So, Above is model class.