getTripAutoEndEnabled method

Future<bool> getTripAutoEndEnabled()

Retrieves the current automatic trip end setting.

Returns whether the SDK is currently configured to automatically detect and stop recording trips when the vehicle stops moving.

Returns:

  • bool: true if automatic trip end is enabled, false otherwise

Usage:

try {
  final autoEndEnabled = await communicator.getTripAutoEndEnabled();
  if (autoEndEnabled) {
    print('Automatic trip end is enabled');
    // Trips will end automatically when stopped
  } else {
    print('Manual trip end required');
    // Show manual stop button
  }
} catch (e) {
  print('Failed to get auto end setting: $e');
}

Throws:

  • Future.error("Unable to get trip auto end pref"): When retrieval fails

Use Cases:

  • Updating UI based on current settings
  • Validating configuration state
  • Settings screen initialization
  • Debugging trip termination issues

Implementation

Future<bool> getTripAutoEndEnabled() async {
  try {
    bool tripAutoEndEnabled = await kruzr_comm.getTripAutoEndEnabled();
    return tripAutoEndEnabled;
  } on Exception catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in getTripAutoEndEnabled");
      print(stackTrace);
      print(e);
    }
    return Future.error("Unable to get trip auto end pref");
  }
}