Map Values
Map values
property returns an iterator to the values in this Map. The type of elements in the returned iterator is as that of the values in Map.
Syntax
The syntax to get an iterator for the values of a Map myMap
is
myMap.values
Examples
Get iterator to values of a Map
In the following Dart Program, we take a Map myMap
with three key-value pairs, and get an iterator for the values using Map.values
property.
main.dart
</>
Copy
void main() {
var myMap = {'apple': 25, 'banana': 10, 'cherry': 6};
var valuesIterator = myMap.values;
print(valuesIterator.elementAt(0));
print(valuesIterator.elementAt(1));
print(valuesIterator.elementAt(2));
}
Output
25
10
6
Conclusion
In this Dart Tutorial, we learned how to get an iterator for the values of a Map, using Map.values
property.