Answers for "iterate object inside object in flutter"

0

how to iterate object in dart

// 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) { });
Posted by: Guest on September-09-2021

Code answers related to "iterate object inside object in flutter"

Code answers related to "Dart"

Browse Popular Code Answers by Language