feat(transport_helper): store vehicle lines in db upon parsing from json

This commit is contained in:
fbachus
2026-07-29 18:31:30 +02:00
parent 0069f370c2
commit 95e3edf699
+5 -1
View File
@@ -812,7 +812,8 @@ class Line {
VehicleType.regionalTrain, VehicleType.regionalTrain,
]; ];
factory Line.fromJson(Map<String, dynamic> json) => Line( factory Line.fromJson(Map<String, dynamic> json) {
Line line = Line(
lineId: json["lineId"] as String, lineId: json["lineId"] as String,
name: json["name"] as String, name: json["name"] as String,
mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)], mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)],
@@ -823,6 +824,9 @@ class Line {
Color.fromJson(json["icon"]["backgroundColor"]) as Color? ?? Color.fromJson(json["icon"]["backgroundColor"]) as Color? ??
Color(r: 50, g: 50, b: 50), // fallback Color(r: 50, g: 50, b: 50), // fallback
); );
line.dbInsert();
return line;
}
static void initLineTable() async { static void initLineTable() async {
Database database = DbHelper.db; Database database = DbHelper.db;
database.execute("""CREATE TABLE IF NOT EXISTS '$tableName'( database.execute("""CREATE TABLE IF NOT EXISTS '$tableName'(