Dart .keys
Anonymous contributor
Published Mar 12, 2024
In Dart, the .keys property returns an iterable collection containing all the keys in a map.
Syntax
myMap.keys
myMap: The map name that needs to be searched.
Example
The following example displays the usage of the .keys property:
void main() {Map<String, String> adventurers = {'001': 'Alice the Archer','002': 'Bob the Barbarian','003': 'Charlie the Cleric'};for (var id in adventurers.keys) {print(id);}}
The above example produces the following output:
001002003
All contributors
- Anonymous contributor
Learn Dart on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours