getPTStopInfo method
- PTStopScheduleFilter? filter,
Retrieve public-transport stop details when available.
This helper calls getPreviewExtendedData and converts the result to a PTStopInfo when the item belongs to CommonOverlayId.publicTransport.
Parameters
filter: Optional departures filter. Narrows only the trips (departures) list - the stops[].routes[] line catalogue is always returned complete. An empty / omitted filter produces the legacy, unfiltered request. See PTStopScheduleFilter.
Returns
- A PTStopInfo when available, otherwise null.
Implementation
Future<PTStopInfo?> getPTStopInfo({PTStopScheduleFilter? filter}) async {
final Completer<PTStopInfo?> completer = Completer<PTStopInfo?>();
if (isOfType(CommonOverlayId.publicTransport)) {
// Trigger the callback-based async operation
getPreviewExtendedData((GemError err, SearchableParameterList? params) {
if (params != null) {
// If successful, complete the Future with PTStopInfo
completer.complete(PTStopInfo.fromParameters(params));
} else {
// In case of an error or null params, complete with null
completer.complete(null);
}
}, filter: filter);
} else {
// If the item isn't of the correct type, complete with null
completer.complete(null);
}
// Return the Future that will eventually be completed
return completer.future;
}