In Dart language how to get MAP keys by values?
I have a Map like;
{
\"01\": \"USD\",
\"17\": \"GBP\",
\"33\": \"EUR\"
}
And I n
There is another one method (similar to Günter Zöchbauer answer):
void main() {
Map currencies = {
"01": "USD",
"17": "GBP",
"33": "EUR"
};
MapEntry entry = currencies.entries.firstWhere((element) => element.value=='GBP', orElse: () => null);
if(entry != null){
print('key = ${entry.key}');
print('value = ${entry.value}');
}
}
In this code, you get MapEntry, which contains key and value, instead only key in a separate variable. It can be useful in some code.