Choose ideal group until selection is implemented
This commit is contained in:
parent
cc7caffffa
commit
a2ebb3def5
1 changed files with 15 additions and 3 deletions
|
|
@ -28,9 +28,21 @@ class TrainData with _$TrainData {
|
|||
|
||||
factory TrainData.fromJson(Map<String, dynamic> json) => _$TrainDataFromJson(json);
|
||||
|
||||
List<TrainDataStation> get stations => groups.first.stations;
|
||||
TrainDataRoute get route => groups.first.route;
|
||||
TrainDataStatus? get status => groups.first.status;
|
||||
TrainDataGroup get idealGroup {
|
||||
var result = groups.first;
|
||||
|
||||
for (final group in groups) {
|
||||
if (result.stations.map((s) => s.linkName).toSet().difference(group.stations.map((s) => s.linkName).toSet()).isEmpty) {
|
||||
result = group;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
List<TrainDataStation> get stations => idealGroup.stations;
|
||||
TrainDataRoute get route => idealGroup.route;
|
||||
TrainDataStatus? get status => idealGroup.status;
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue