I'm just starting with Flutter and I'm struggling with lists and maps, so if anyone mind to help it would be great!
What I is to make a simple list like
['Johh', 'Will', 'Mary']
to a List<Map<String, Object>> like
{'Name': 'John', 'Aplication' : Datetime.now()},
{'Name': 'Will', 'Aplication' : Datetime.now()},
{'Name': 'Mary', 'Aplication' : Datetime.now()}
I've read so many forums but still didn't get it.
CodePudding user response:
Here is an option for converting a list to a list of Map<String, object>
void main() async {
List data = ['Johh', 'Will', 'Mary'];
var newData = data.map((val) {
return {'name': val, 'application': DateTime.now()};
}).toList();
print(newData);
}
I recommend checking out https://www.tutorialspoint.com/dart_programming/dart_programming_map.htm it is a good source of information and easy to follow.