How to get Map keys by values in Dart?
问题 In Dart language how to get MAP keys by values? I have a Map like; { "01": "USD", "17": "GBP", "33": "EUR" } And I need to use values to get keys. How do I do that? 回答1: var usdKey = curr.keys.firstWhere( (k) => curr[k] == 'USD', orElse: () => null); 回答2: If you will be doing this more than a few times on the same data, you should create an inverse map so that you can perform simple key lookup instead of repeated linear searches. Here's an example of reversing a map (there may be easier ways