Public Access
feat(transport_helper): add fromJson constructor for Departure class
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user