setTripAutoEndEnabled method
Enables or disables automatic trip end detection.
Controls whether the SDK should automatically detect and stop recording trips when the vehicle stops moving for a sufficient duration. When enabled, the SDK will automatically end trip recording based on movement patterns.
Parameters:
shouldAutoEnd:trueto enable automatic trip end,falseto disable
Usage:
try {
// Enable automatic trip end
await communicator.setTripAutoEndEnabled(true);
print('Automatic trip end enabled');
// Disable automatic trip end (manual end only)
await communicator.setTripAutoEndEnabled(false);
print('Automatic trip end disabled - manual end required');
} catch (e) {
print('Failed to change auto end setting: $e');
}
Throws:
Future.error("Unable to change trip auto end pref"): When setting update fails
Important Notes:
- Setting persists across app sessions
- When disabled, trips must be stopped manually using stopTrip
- Overrides the initial configuration from Kruzr360InitConfig
- Changes take effect immediately for active trips
Use Cases:
- User preference settings
- Fleet management policies
- Long stop scenarios (gas stations, shopping)
- Testing and debugging scenarios
Implementation
Future<void> setTripAutoEndEnabled(bool shouldAutoEnd) async {
try {
await kruzr_comm.setTripAutoEndEnabled(shouldAutoEnd);
} on Exception catch (e, stackTrace) {
if (kDebugMode) {
print("Error in setTripAutoEndEnabled");
print(stackTrace);
print(e);
}
return Future.error("Unable to change trip auto end pref");
}
return;
}