getAllCountries static method
Get information about countries
Future<List<Country>> getAllCountries(){
try{
List<Country> countries = await CountryProvider.getAllCountries();
return result;
} catch(error) {
}
}
Implementation
static Future<List<Country>> getAllCountries({CountryFilter? filter}) async {
var uri =
"$_baseUrl" + Constants.allCountrySiffixUri + filter.toFormattedUri;
// print(uri);
var response = await _client.get(Uri.parse(uri));
if (response.statusCode == 200) {
var countries = List<Country>.from(
jsonDecode(response.body).map((x) => Country.fromJson(x)));
// print("Get Country sucessfull");
return countries;
}
throw new Exception(
"No country found. Please check if https://restcountries.eu is avialable.");
}