'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?
Solution 1:[1]
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
Solution 2:[2]
Map myMap = {"name":"mike", "age":"12};
List myList = myMap.values.toList();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MaNDOOoo |
| Solution 2 | Huthaifa Muayyad |
