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