diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index 2289b73..ca84870 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -779,17 +779,21 @@ class Departure { static const String tableName = "departure"; int? id; + String ref; String vehicleId; String vehicleName; String stationId; + String stationName; DateTime arrivalTime; DateTime departureTime; Departure({ this.id, + required this.ref, required this.vehicleId, required this.vehicleName, required this.stationId, + required this.stationName, required this.arrivalTime, required this.departureTime, }); @@ -797,9 +801,11 @@ class Departure { Map _toMap() { return { "id": id, + "ref": ref, "vehicle": vehicleId, "vehiclename": vehicleName, "station": stationId, + "stationname": stationName, "arrivaltime": arrivalTime, "departuretime": departureTime, }; @@ -808,9 +814,11 @@ class Departure { factory Departure.fromMap(Map map) { return Departure( id: map["id"] as int, + ref: map["ref"] as String, vehicleId: map["vehicle"] as String, vehicleName: map["vehiclename"] as String, stationId: map["station"] as String, + stationName: map["stationname"] as String, arrivalTime: map["arrivaltime"] as DateTime, departureTime: map["departuretime"] as DateTime, ); @@ -847,9 +855,11 @@ class Departure { } return Departure( + ref: json["JourneyDetailRef"]["ref"], vehicleId: vehicle.id, vehicleName: vehicle.name, stationId: station.id, + stationName: station.name, arrivalTime: arrDateTime ?? depDateTime as DateTime, // one of these has to be in the json @@ -865,8 +875,12 @@ class Departure { String station = Station.tableName; database.execute("""CREATE TABLE IF NOT EXISTS $tableName( id INTEGER, + ref TEXT, vehicle TEXT, + vehiclename TEXT, station TEXT, + stationname TEXT, + arrivaltime TEXT, departuretime TEXT, FOREIGN KEY(vehicle) REFERENCES $vehicle(id), FOREIGN KEY(station) REFERENCES $station(id)