eskemender
eskemender

Reputation: 119

flutter convert map to list without key

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?

Upvotes: 1

Views: 4601

Answers (2)

Huthaifa Muayyad
Huthaifa Muayyad

Reputation: 12353

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

Upvotes: 1

MaNDOOoo
MaNDOOoo

Reputation: 1555

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

Upvotes: 6

Related Questions