I am looking for an elegant way to convert a List where we remove the object information and keep only a specific property.
example: List< Fruit> becomes List with the property fruitColor (a String) kept.
I am looking for an elegant way to convert a List where we remove the object information and keep only a specific property.
example: List< Fruit> becomes List with the property fruitColor (a String) kept.
I think you're looking for:
var listOfFruit = ...;
var listOfColors = listOfFruit.map((e) => e.fruitColor).toList();