Public Access
feat(transport_helper): store vehicle lines in db upon parsing from json
This commit is contained in:
+15
-11
@@ -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'(
|
||||
|
||||
Reference in New Issue
Block a user