isTripAutoStartEnabled method

Future<bool> isTripAutoStartEnabled()

Retrieves the current automatic trip start setting.

Returns whether the SDK is currently configured to automatically detect and start recording trips based on vehicle movement patterns.

Returns:

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

Usage:

try {
  final autoStartEnabled = await communicator.isTripAutoStartEnabled();
  if (autoStartEnabled) {
    print('Automatic trip start is enabled');
    // Show UI indicating automatic mode
  } else {
    print('Manual trip start required');
    // Show manual start button
  }
} catch (e) {
  print('Failed to get auto start setting: $e');
}

Throws:

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

Use Cases:

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

Implementation

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