feat(transport_helper): add fromJson constructor for Departure class

This commit is contained in:
fbachus
2026-07-20 14:45:53 +02:00
parent 89a0f9b3c9
commit 25d5e241eb
+12 -1
View File
@@ -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<String, dynamic> 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;