How to get Map keys by values in Dart?

前端 未结 6 1506
小蘑菇
小蘑菇 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:35

    Map map = {1: 'one', 2: 'two', 3: 'three'};
    
    var key = map.keys.firstWhere((k) => map[k] == 'two', orElse: () => null);
    print(key);
    

提交回复
热议问题