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);
|
factory TrainData.fromJson(Map<String, dynamic> json) => _$TrainDataFromJson(json);
|
||||||
|
|
||||||
List<TrainDataStation> get stations => groups.first.stations;
|
TrainDataGroup get idealGroup {
|
||||||
TrainDataRoute get route => groups.first.route;
|
var result = groups.first;
|
||||||
TrainDataStatus? get status => groups.first.status;
|
|
||||||
|
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
|
@freezed
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue