getTripUpdates method

Future<List<BusTripUpdate>> getTripUpdates ()

Returns a List of BusTripUpdate objects.

Implementation

Future<List<BusTripUpdate>> getTripUpdates() async {
  var response = await http
      .get('http://64.128.172.149:8080/gtfsrealtime/TripUpdates');

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

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