getTripShareUrl method

Future<ShareableTripUrlResponseModel?> getTripShareUrl(
  1. String appTripId
)

Generates a shareable URL for a specific trip.

Creates a public URL that can be shared with others to view trip details without requiring the Kruzr app or authentication.

Parameters:

  • appTripId: Unique identifier for the trip to share

Returns:

  • ShareableTripUrlResponseModel?: URL response containing shareable link, or null if failed

Usage:

try {
  final shareableUrl = await communicator.getTripShareUrl('trip-123');
  if (shareableUrl != null) {
    print('Share this trip: ${shareableUrl.url}');
    // Copy to clipboard or share via social media
  }
} catch (e) {
  print('Failed to generate shareable URL: $e');
}

Throws:

  • Future.error("Unable to generate trip link"): When URL generation fails

Use Cases:

  • Social media sharing
  • Family and friends trip sharing
  • Public trip showcasing

Implementation

Future<ShareableTripUrlResponseModel?> getTripShareUrl(
    String appTripId,
    ) async {
  try {
    ShareableTripUrlResponseModel? shareableTripUrlResponseModel =
    await kruzr_comm.getTripShareUrlById(appTripId);
    return shareableTripUrlResponseModel;
  } on PlatformException catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in getTripShareUrl");
      print(stackTrace);
      print(e);
    }
    return Future.error({"code": e.code, "message": e.message, "details": e.details});
  } on Exception catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in getTripShareUrl");
      print(stackTrace);
      print(e);
    }
    return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
  }
}