getVehicleUpdates method

Future<List<BusVehicleUpdate>> getVehicleUpdates ()

Returns a List of BusVehicleUpdate objects.

Implementation

Future<List<BusVehicleUpdate>> getVehicleUpdates() async {
  var response = await http
      .get('http://64.128.172.149:8080/gtfsrealtime/VehiclePositions');

  Set<String> routeIds = {'87', '286', '289'};

  List<BusVehicleUpdate> vehicleUpdatesList = response != null
      ? FeedMessage.fromBuffer(response.bodyBytes)
          .entity
          .map((entity) => BusVehicleUpdate.fromPBEntity(entity))
          .where((update) => routeIds.contains(update.routeId))
          .toList()
      : [];
  return vehicleUpdatesList;
}