areaFilter function

Future<List<String>> areaFilter()

List the area filter.

Returns List of String.

Implementation

Future<List<String>> areaFilter() async {
  try {
    var response = await _getRequest("list.php?a=list");
    if (response.length == 0) {
      throw "no results found";
    }
    var json = jsonDecode(response);
    if (json["meals"] == null || json["meals"].length == 0) {
      throw "no results found";
    }
    List<String> list = [];
    for (var i in json["meals"]) {
      list.add(i["strArea"]);
    }
    return list;
  } catch(ex) {
    throw new MealDBException(ex.toString());
  }
}