fetchTripDetailsByAppTripId method
Retrieves detailed information for a specific trip using its app trip ID.
Fetches comprehensive trip details including route information, driving behavior analysis, duration, distance, and safety metrics.
Parameters:
appTripId: Unique identifier for the trip
Returns:
SingleTripResponse?: Detailed trip information, ornullif not found
Usage:
try {
final tripDetails = await communicator.fetchTripDetailsByAppTripId('trip-123');
if (tripDetails != null) {
print('Trip date: ${tripDetails.startTime}');
print('Distance: ${tripDetails.distance} km');
print('Duration: ${tripDetails.duration} minutes');
print('Safety score: ${tripDetails.safetyScore}');
}
} catch (e) {
print('Failed to fetch trip details: $e');
}
Throws:
Future.error("Unable to get trip details"): When retrieval fails
Use Cases:
- Trip history viewing
- Detailed trip analysis
- Trip sharing and reporting
Implementation
Future<SingleTripResponse?> fetchTripDetailsByAppTripId(
String appTripId,
) async {
try {
SingleTripResponse? singleTripResponse = await kruzr_comm
.fetchTripDetailsByAppTripId(appTripId);
return singleTripResponse;
} on Exception catch (e, stackTrace) {
if (kDebugMode) {
print("Error in fetchTripDetailsByAppTripId");
print(stackTrace);
print(e);
}
return Future.error("Unable to get trip details");
}
}