Reputation: 43
I have the following Map
{
"Afghanistan": "A004",
"Albanien": "A008",
"Algerien": "A012",
"Amerikanisch-Samoa": "A016",
"Amerikanische Jungferninseln": "A850",
"Andorra": "A020" }
i'm Mapping it with
final landcodes =
Map<String, String>.fromIterables(countryList, codeList);
I am now trying to extract one value by providing one key with the following code:
var value = landcodes.values.firstWhere((element) => landcodes[element]
== 'Andorra');
But everytime i get the following error-response:
Unhandled Exception: Unhandled error Bad state: No element occurred in Instance of 'AdressAenderungBloc'.
#0 Iterable.firstWhere (dart:core/iterable.dart:516:5)
Upvotes: 1
Views: 16357
Reputation: 1
void main() {var details = new Map(); details['Usrname1'] = 'admin1';details['Password1'] = 'admin@123'; details['Usrname2'] = 'admin2';details['Password2'] = 'admin@123'; print('${details.keys}'); }
Upvotes: -2
Reputation: 782
I think you are mixing country and code. Retrieving the code based on the country:
var code = landcodes['Andorra'];
Or retrieving the country like this:
var country = landcodes.entries.firstWhere((entry) => entry.value
== 'A020').key;
Upvotes: 9