ingredientsFilter function
List the ingredients filter.
Returns List of String.
Implementation
Future<List<String>> ingredientsFilter() async {
try {
var response = await _getRequest("list.php?i=list");
if (response.length == 0) {
throw "no results found";
}
var json = jsonDecode(response);
if (json["drinks"] == null || json["drinks"].length == 0) {
throw "no results found";
}
List<String> list = [];
for (var i in json["drinks"]) {
list.add(i["strIngredient1"]);
}
return list;
} catch(ex) {
throw new CocktailDBException(ex.toString());
}
}