How to get Map keys by values in Dart?

前端 未结 6 1531
小蘑菇
小蘑菇 2021-02-05 00:43

In Dart language how to get MAP keys by values?

I have a Map like;

{
  \"01\": \"USD\",
  \"17\": \"GBP\",
  \"33\": \"EUR\"
}

And I n

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 01:26

    You can do the following :

    var mapper = { 
                  '01' : 'USD',
                   '17' : 'GBP'     } 
    
    for(var val in mapper.keys){
    
      switch(mapper[val]){
    
            case 'USD' : {
                                 print('key for ${mapper[val]} is : ' '${val}');  
                }
    
              break;
    
            case 'GBP' : {
                                 print('key for ${mapper[val]} is : ' '${val}');   
                   } 
    
            }
              }
    

提交回复
热议问题