locationParser static method
Parses a WebSocket message into the appropriate model.
Types: position → BusPosition, esta-info → RouteStationInfo,
stop → BusStopped, close → ConnectionClose.
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"]}");
}
}