store objects in list dart code example
Example: how to store list of object in dart
class Customer {
String name;
int age;
Customer(this.name, this.age);
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);
}