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
+15 -11
View File
@@ -812,17 +812,21 @@ class Line {
VehicleType.regionalTrain,
];
factory Line.fromJson(Map<String, dynamic> json) => Line(
lineId: json["lineId"] as String,
name: json["name"] as String,
mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)],
fgColor:
Color.fromJson(json["icon"]["foregroundColor"]) as Color? ??
Color(r: 255, g: 255, b: 255), // fallback
bgColor:
Color.fromJson(json["icon"]["backgroundColor"]) as Color? ??
Color(r: 50, g: 50, b: 50), // fallback
);
factory Line.fromJson(Map<String, dynamic> json) {
Line line = Line(
lineId: json["lineId"] as String,
name: json["name"] as String,
mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)],
fgColor:
Color.fromJson(json["icon"]["foregroundColor"]) as Color? ??
Color(r: 255, g: 255, b: 255), // fallback
bgColor:
Color.fromJson(json["icon"]["backgroundColor"]) as Color? ??
Color(r: 50, g: 50, b: 50), // fallback
);
line.dbInsert();
return line;
}
static void initLineTable() async {
Database database = DbHelper.db;
database.execute("""CREATE TABLE IF NOT EXISTS '$tableName'(