getStops method
Getter method to retrieve the list of stops
Implementation
Future<List<ShuttleStop>> getStops() async {
/// Returns a list of shuttle stops.
///
/// Fetch 'stops' data from JSON API and store in variable 'response'
/// If unable to retreive data, response is set equal to null.
/// Create list to store data.
/// Decode the data and insert values into the list.
///
///
/// return stopsList;
var response = await fetch('stops');
List<ShuttleStop> stopsList = response != null
? json
.decode(response.body)
.map<ShuttleStop>((json) => ShuttleStop.fromJson(json))
.toList()
: [];
return stopsList;
}