Hi,
I've been trying to figure how to get the index from my list with map() class.
My List
class MyTestList {
MyTestList({this.title});
String title;
}
List<MyTestList> myTestList = [
MyTestList(title: "Foo 1"),
MyTestList(title: "Foo 2"),
MyTestList(title: "Foo 3"),
];
I know how to get the value from title key
Map class
myTestList.map((item) {
print(item.title);
}).toList();
But how can I get the index?
I would like to have something like this
myTestList.map((item) {
print('$index: ${item.title}');
}).toList();
// 0: Foo 1
// 1: Foo 2
// 2: Foo 3
Thank you
Marc