isTripAutoEndEnabled method

Future<bool> isTripAutoEndEnabled()

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.isTripAutoEndEnabled();
  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> isTripAutoEndEnabled() async {
  try {
    bool tripAutoEndEnabled = await kruzr_comm.isTripAutoEndEnabled();
    return tripAutoEndEnabled;
  } on PlatformException catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in isTripAutoEndEnabled");
      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 isTripAutoEndEnabled");
      print(stackTrace);
      print(e);
    }
    return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
  }
}