set trip to null, not 0
Some checks failed
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 1m13s
Release / android-build (push) Successful in 11m2s
Release / release-master (push) Successful in 3s
Release / release-dev (push) Successful in 14s
Release / windows-build (push) Has been cancelled
Some checks failed
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 1m13s
Release / android-build (push) Successful in 11m2s
Release / release-master (push) Successful in 3s
Release / release-dev (push) Successful in 14s
Release / windows-build (push) Has been cancelled
This commit is contained in:
@@ -140,7 +140,7 @@ class LocoSummary extends Loco {
|
||||
required String locoType,
|
||||
required String locoNumber,
|
||||
required String locoName,
|
||||
required String locoClass,
|
||||
required super.locoClass,
|
||||
required String locoOperator,
|
||||
String? locoNotes,
|
||||
String? locoEvn,
|
||||
@@ -153,43 +153,41 @@ class LocoSummary extends Loco {
|
||||
this.livery,
|
||||
this.location,
|
||||
Map<String, dynamic>? extra,
|
||||
}) : extra = extra ?? const {},
|
||||
super(
|
||||
}) : extra = extra ?? const {},
|
||||
super(
|
||||
id: locoId,
|
||||
type: locoType,
|
||||
number: locoNumber,
|
||||
name: locoName,
|
||||
locoClass: locoClass,
|
||||
operator: locoOperator,
|
||||
notes: locoNotes,
|
||||
evn: locoEvn,
|
||||
);
|
||||
|
||||
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
|
||||
locoId: json['loco_id'] ?? json['id'] ?? 0,
|
||||
locoType: json['type'] ?? json['loco_type'] ?? '',
|
||||
locoNumber: json['number'] ?? json['loco_number'] ?? '',
|
||||
locoName: json['name'] ?? json['loco_name'] ?? "",
|
||||
locoClass: json['class'] ?? json['loco_class'] ?? '',
|
||||
locoOperator: json['operator'] ?? json['loco_operator'] ?? '',
|
||||
locoNotes: json['notes'],
|
||||
locoEvn: json['evn'] ?? json['loco_evn'],
|
||||
mileage: ((json['loco_mileage'] ?? json['mileage']) as num?)
|
||||
?.toDouble() ??
|
||||
0,
|
||||
journeys: (json['loco_journeys'] ?? json['journeys'] ?? 0) is num
|
||||
? (json['loco_journeys'] ?? json['journeys'] ?? 0).toInt()
|
||||
: 0,
|
||||
trips: (json['loco_trips'] ?? json['trips']) is num
|
||||
? (json['loco_trips'] ?? json['trips']).toInt()
|
||||
: null,
|
||||
status: json['status'] ?? json['loco_status'],
|
||||
domain: json['domain'],
|
||||
owner: json['owner'] ?? json['loco_owner'],
|
||||
livery: json['livery'],
|
||||
location: json['location'],
|
||||
extra: Map<String, dynamic>.from(json),
|
||||
);
|
||||
locoId: json['loco_id'] ?? json['id'] ?? 0,
|
||||
locoType: json['type'] ?? json['loco_type'] ?? '',
|
||||
locoNumber: json['number'] ?? json['loco_number'] ?? '',
|
||||
locoName: json['name'] ?? json['loco_name'] ?? "",
|
||||
locoClass: json['class'] ?? json['loco_class'] ?? '',
|
||||
locoOperator: json['operator'] ?? json['loco_operator'] ?? '',
|
||||
locoNotes: json['notes'],
|
||||
locoEvn: json['evn'] ?? json['loco_evn'],
|
||||
mileage:
|
||||
((json['loco_mileage'] ?? json['mileage']) as num?)?.toDouble() ?? 0,
|
||||
journeys: (json['loco_journeys'] ?? json['journeys'] ?? 0) is num
|
||||
? (json['loco_journeys'] ?? json['journeys'] ?? 0).toInt()
|
||||
: 0,
|
||||
trips: (json['loco_trips'] ?? json['trips']) is num
|
||||
? (json['loco_trips'] ?? json['trips']).toInt()
|
||||
: null,
|
||||
status: json['status'] ?? json['loco_status'],
|
||||
domain: json['domain'],
|
||||
owner: json['owner'] ?? json['loco_owner'],
|
||||
livery: json['livery'],
|
||||
location: json['location'],
|
||||
extra: Map<String, dynamic>.from(json),
|
||||
);
|
||||
}
|
||||
|
||||
class LeaderboardEntry {
|
||||
@@ -353,24 +351,23 @@ class TripLeg {
|
||||
});
|
||||
|
||||
factory TripLeg.fromJson(Map<String, dynamic> json) => TripLeg(
|
||||
id: json['leg_id'],
|
||||
start: json['leg_start'] ?? '',
|
||||
end: json['leg_end'] ?? '',
|
||||
beginTime:
|
||||
json['leg_begin_time'] != null && json['leg_begin_time'] is String
|
||||
? DateTime.tryParse(json['leg_begin_time'])
|
||||
: (json['leg_begin_time'] is DateTime
|
||||
? json['leg_begin_time']
|
||||
: null),
|
||||
network: json['leg_network'],
|
||||
route: json['leg_route'],
|
||||
mileage: (json['leg_mileage'] as num?)?.toDouble(),
|
||||
notes: json['leg_notes'],
|
||||
locos: (json['locos'] as List?)
|
||||
?.map((e) => Loco.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
id: json['leg_id'],
|
||||
start: json['leg_start'] ?? '',
|
||||
end: json['leg_end'] ?? '',
|
||||
beginTime:
|
||||
json['leg_begin_time'] != null && json['leg_begin_time'] is String
|
||||
? DateTime.tryParse(json['leg_begin_time'])
|
||||
: (json['leg_begin_time'] is DateTime ? json['leg_begin_time'] : null),
|
||||
network: json['leg_network'],
|
||||
route: json['leg_route'],
|
||||
mileage: (json['leg_mileage'] as num?)?.toDouble(),
|
||||
notes: json['leg_notes'],
|
||||
locos:
|
||||
(json['locos'] as List?)
|
||||
?.map((e) => Loco.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
class TripDetail {
|
||||
@@ -389,14 +386,14 @@ class TripDetail {
|
||||
});
|
||||
|
||||
factory TripDetail.fromJson(Map<String, dynamic> json) => TripDetail(
|
||||
id: json['trip_id'] ?? 0,
|
||||
name: json['trip_name'] ?? '',
|
||||
mileage: (json['trip_mileage'] as num?)?.toDouble() ?? 0,
|
||||
legCount: json['leg_count'] ??
|
||||
((json['trip_legs'] as List?)?.length ?? 0),
|
||||
legs: (json['trip_legs'] as List?)
|
||||
?.map((e) => TripLeg.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
id: json['trip_id'] ?? 0,
|
||||
name: json['trip_name'] ?? '',
|
||||
mileage: (json['trip_mileage'] as num?)?.toDouble() ?? 0,
|
||||
legCount: json['leg_count'] ?? ((json['trip_legs'] as List?)?.length ?? 0),
|
||||
legs:
|
||||
(json['trip_legs'] as List?)
|
||||
?.map((e) => TripLeg.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user