generateRandomArabianCountry method
Implementation
List<Country> generateRandomArabianCountry(int lengthCountries) {
final List<Country> arabianCountries = [];
if (lengthCountries > 20 || lengthCountries < 1) {
throw Exception("Length can`t be more 20 or less than 1");
}
while (arabianCountries.length < lengthCountries) {
for (var i in countries) {
if (i["is_arabian_country"] &&
arabianCountries
.where((element) => element.name == i["name"])
.isEmpty) {
arabianCountries.add(Country.fromJson(i));
break;
}
}
}
return arabianCountries;
}