getTrip method

Future<List<BusTrip>> getTrip ()

Returns a List of BusTrip objects.

Implementation

Future<List<BusTrip>> getTrip() async {
  var response = await fetch('busTrips', query: {
    'query': '{"route_id": ["87-184","286-184","289-184"]}'
  }); //trips for 87,286 and 289

  List<BusTrip> tripList = response != null
      ? json
          .decode(response.body)
          .map<BusTrip>((json) => BusTrip.fromJson(json))
          .toList()
      : [];

  return tripList;
}