dart create list from object properties

The solution for “dart create list from object properties” can be found here. The following code will assist you in solving the problem.

class City {
const City(this.id, this.name);

final int id;
final String name;

List cities = [
City(0, ‘A’),
City(1, ‘B’),
City(2, ‘C’),

final List cityNames = cities.map((city) => city.name).toList();

void main() {

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in