getPTStopInfo method
Get the PTStopInfo object for this item.
Returns
- The PTStopInfo object if the item is of type CommonOverlayId.publicTransport
- null if the item is not of type CommonOverlayId.publicTransport
Implementation
Future<PTStopInfo?> getPTStopInfo() async {
final completer = Completer<PTStopInfo?>();
if (isOfType(CommonOverlayId.publicTransport)) {
// Trigger the callback-based async operation
getPreviewExtendedData((err, 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);
}
});
} 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;
}