From e71492141e31570fba81936adaa318ca1a830e2f Mon Sep 17 00:00:00 2001 From: fbachus Date: Wed, 22 Jul 2026 02:06:53 +0200 Subject: [PATCH] feat(transport_helper: add "ref" to Segments for journeyDetails later --- lib/transport_helper.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index 89fcabf..955e090 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -309,7 +309,9 @@ class Route { class Segment { static const String tableName = "segment"; + // TODO: add attribute for departures on the way? int? id; + String ref; Station startPoint; Station endPoint; DateTime startTime; @@ -318,6 +320,7 @@ class Segment { Segment({ this.id, // might throw errors - needs testing, I guess + required this.ref, required this.startPoint, required this.endPoint, required this.startTime, @@ -327,6 +330,7 @@ class Segment { Map toMap() { return { + "ref": ref, "startpoint": startPoint.id, "endpoint": endPoint.id, "starttime": startTime, @@ -338,6 +342,7 @@ class Segment { factory Segment.fromMap(Map map) { return Segment( id: map["id"] as int, + ref: map["ref"] as String, startPoint: map["startPoint"] as Station, endPoint: map["endPoint"] as Station, startTime: map["startTime"] as DateTime, @@ -348,6 +353,7 @@ class Segment { factory Segment.fromJson(Map json) { Segment tmp = Segment( + ref: json["JourneyDetail"]["ref"], startPoint: Station.fromJson(json["Origin"]), endPoint: Station.fromJson(json["Destination"]), startTime: json["Origin"]["rtTime"], @@ -372,6 +378,8 @@ class Segment { String vehicle = Vehicle.tableName; database.execute(""" CREATE TABLE IF NOT EXISTS $tableName( + id INTEGER PRIMARY KEY AUTOINCREMENT, + ref TEXT, startpoint TEXT, endpoint TEXT, starttime TEXT, @@ -943,4 +951,4 @@ enum VehicleType { subway, regionalTrain, PLACEHOLDER, -} +} \ No newline at end of file