DART Loop через объект
var usrMap = {"name": "Tom", 'Email': 'tom@xyz.com'};
usrMap.forEach((k,v) => print('${k}: ${v}'));
Evil Eel
var usrMap = {"name": "Tom", 'Email': 'tom@xyz.com'};
usrMap.forEach((k,v) => print('${k}: ${v}'));
// You have several options, the simple way for me is
// create method "toJson" inside of the class,
// and then iterate over the return of method "toJson".
example :
class MyModel() {
int value1;
String value2;
bool value3;
MyModel({
this.key1,
this.key2,
this.key3});
Map<String, dynamic> toJson() {
return {"key1": value1,
"key2":value2,
"key3":value3 };}
}
MyModel.toJson().forEach((key, value) { });