getPTStopInfo method

Future<PTStopInfo?> getPTStopInfo()

Get the PTStopInfo object for this item.

Returns

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;
}