Answers for "how to store list of object in dart"

0

how to store list of object in dart

class Customer {
  String name;
  int age;

  Customer(this.name, this.age);

  @override
  String toString() {
    return '{ ${this.name}, ${this.age} }';
  }
}

main() {
  List customers = [];
  customers.add(Customer('Jack', 23));
  customers.add(Customer('Adam', 27));
  customers.add(Customer('Katherin', 25));

  print(customers);
  print(customers.length);
}
Posted by: Guest on March-16-2021

Code answers related to "how to store list of object in dart"

Code answers related to "Dart"

Browse Popular Code Answers by Language