TrainPosition.fromJson constructor
Creates a new TrainPosition object from a JSON map.
Implementation
factory TrainPosition.fromJson(Map<String, dynamic> json) {
return TrainPosition(
numCars: ((json[ApiFields.carCount] ?? -1) as num).toInt(),
circuitId: (json[ApiFields.circuitId] ?? -1).toString(),
destinationStationCode: json[ApiFields.destinationStationCode],
directionNum: ((json[ApiFields.directionNum] ?? -1) as num).toInt(),
lineCode: json[ApiFields.lineCode],
secondsAtLocation:
((json[ApiFields.secondsAtLocation] ?? -1) as num).toInt(),
serviceType: ServiceType.fromString(
json[ApiFields.serviceType] ?? ServiceType.unknown.value),
trainId: json[ApiFields.trainId] ?? '',
trainNumber: json[ApiFields.trainNumber] ?? '',
);
}