How to print map keys in Dart

2 Answers

0 votes
void main() {
    var mp = {'dart': 13, 'c': 89, 'c++': 10, 'python': 45};
    
    var keys = mp.keys;
     
    for (int i = 0; i < mp.length; i++) {
        print(keys.elementAt(i));
    }
}
 
 
 
 
 
/*
run:
 
dart
c
c++
python
 
*/

 



answered Oct 11, 2022 by avibootz
0 votes
void main() {
    var mp = {'dart': 13, 'c': 89, 'c++': 10, 'python': 45};
    
    print(mp.keys);
}
 
 
 
 
 
/*
run:
 
(dart, c, c++, python)
 
*/

 



answered Oct 11, 2022 by avibootz

Related questions

1 answer 172 views
2 answers 165 views
2 answers 140 views
140 views asked Oct 11, 2022 by avibootz
2 answers 159 views
159 views asked Oct 11, 2022 by avibootz
2 answers 156 views
156 views asked Oct 11, 2022 by avibootz
1 answer 160 views
1 answer 145 views
...