locationParser static method

Object locationParser(
  1. Map json
)

Parses a WebSocket message into the appropriate model. Types: positionBusPosition, esta-infoRouteStationInfo, stopBusStopped, closeConnectionClose.

Implementation

static Object locationParser(Map json) {
  if (json["type"] == "position") {
    return BusPosition.fromJson(json);
  } else if (json["type"] == "esta-info") {
    return RouteStationInfo.fromJson(json);
  } else if (json["type"] == "stop") {
    return BusStopped.fromJson(json);
  } else if (json["type"] == "close") {
    return ConnectionClose();
  } else {
    throw UnimplementedError("Unknown type: ${json["type"]}");
  }
}