Home > Blockchain >  flutter convert map to list without key
flutter convert map to list without key

Time:04-12

How can I convert a map like

 {
  "name": "my name",
  "date": "14 Feb 2020",
  "days": "15",
 }

Into something like

[
 "my name",
 "14 Feb 2020"
 "15"
]

Basically converting map values into List.

I've tried

list.add(name) and so on

but there will be problems if there is many data. Is there any way to iterate to get the expected result?

CodePudding user response:

You can get a value list using the values getter.

final map = {
  "name": "my name",
  "date": "14 Feb 2020",
  "days": "15",
};

map.values.toList(); // <---- Here

CodePudding user response:

Map myMap = {"name":"mike", "age":"12};
List myList = myMap.values.toList();
  • Related