startTrip method

Future<bool> startTrip()

Manually starts a new trip.

Initiates trip recording and monitoring. This method is useful for manual trip tracking when automatic detection is not sufficient.

Returns:

  • bool: true if trip started successfully, false otherwise

Usage:

try {
  final started = await communicator.startTrip();
  if (started) {
    print('Trip started successfully');
    // Update UI to show trip is active
  } else {
    print('Failed to start trip');
  }
} catch (e) {
  print('Error starting trip: $e');
}

Throws:

  • Future.error("Unable to start trip"): When trip start fails

Prerequisites:

  • User must be logged in
  • Location permissions must be granted
  • Trip monitoring must be initiated

Use Cases:

  • Manual trip tracking
  • Override automatic detection
  • Testing trip functionality

Implementation

Future<bool> startTrip() async {
  try {
    bool tripStarted = await kruzr_comm.startTrip();
    return tripStarted;
  } on Exception catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in startTrip");
      print(stackTrace);
      print(e);
    }
    return Future.error("Unable to start trip");
  }
}