I have a list of all countries like this:
List<Map<String, Object>> allCountries = [
{
"name": "Afghanistan",
"code": "AF",
"capital": "Kabul",
"region": "AS",
"currency": {"code": "AFN", "name": "Afghan afghani", "symbol": "؋"},
"language": {"code": "ps", "name": "Pashto"},
"flag": "https://restcountries.eu/data/afg.svg",
"dialling_code": "+93"
},
.................
{
"name": "Zimbabwe",
"code": "ZW",
"capital": "Harare",
"region": "AF",
"currency": {"code": "BWP", "name": "Botswana pula", "symbol": "P"},
"language": {
"code": "en",
"iso639_2": "eng",
"name": "English",
"nativeName": "English"
},
"flag": "https://restcountries.eu/data/zwe.svg",
"dialling_code": "+263"
}
];
I want to create another List<Map<String, Object>> resultOfQuery from the original list but only when the query match or start with a name of country.
How can this be done ?
Use this method:
and you can use it like this: