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 180 views
2 answers 177 views
2 answers 151 views
151 views asked Oct 11, 2022 by avibootz
2 answers 173 views
173 views asked Oct 11, 2022 by avibootz
2 answers 172 views
172 views asked Oct 11, 2022 by avibootz
1 answer 169 views
1 answer 150 views
...