From 25d5e241eb13fbfacb03d70c29455221352426ca Mon Sep 17 00:00:00 2001 From: fbachus Date: Mon, 20 Jul 2026 14:45:53 +0200 Subject: [PATCH] feat(transport_helper): add fromJson constructor for Departure class --- lib/transport_helper.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index b4050eb..3a0fa4a 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -739,7 +739,6 @@ class Line { } } -// TODO: add fromJson class Departure { static const String tableName = "departure"; @@ -772,6 +771,18 @@ class Departure { departureTime: map["departuretime"] as DateTime, ); } + factory Departure.fromJson(Map json) { + Vehicle vehicle = Vehicle.fromJson(json["Product"]); + vehicle.dbInsert(); + Station station = Station.fromJson(json["stop"]); + station.dbInsert(); + return Departure( + vehicleId: vehicle.id, + stationId: station.id, + departureTime: json["time"], + ); + } + static void initDepartureTable() async { Database database = DbHelper.db; String vehicle = Vehicle.tableName;