getAutoTripStartOnlyIfVehicleConnected method
Retrieves the current automatic trip start only if vehicle connected setting.
Returns whether the SDK is currently configured to automatically detect and start recording trips based on vehicle movement patterns only when saved vehicle is connected.
Returns:
bool:trueif automatic trip start is enabled,falseotherwise
Usage:
try {
final autoStartEnabled = await communicator.getAutoTripStartOnlyIfVehicleConnected();
if (autoStartEnabled) {
print('Automatic trip start when vehicle connected 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 auto trip start only if vehicle connected 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> getAutoTripStartOnlyIfVehicleConnected() async {
try {
bool tripAutoStartEnabled = await kruzr_comm
.getAutoTripStartOnlyIfVehicleConnected();
return tripAutoStartEnabled;
} on Exception catch (e, stackTrace) {
if (kDebugMode) {
print("Error in getAutoTripStartOnlyIfVehicleConnected");
print(stackTrace);
print(e);
}
return Future.error(
"Unable to get auto trip start only if vehicle connected pref",
);
}
}