logout method

Future<void> logout()

Logs out the current user from the Kruzr system.

Clears all user session data and stops any ongoing trip monitoring. After logout, the user will need to authenticate again to use SDK features.

Usage:

try {
  await communicator.logout();
  print('User logged out successfully');
} catch (e) {
  print('Logout failed: $e');
}

Throws:

  • Future.error("Unable to logout user"): When logout operation fails

Important Notes:

  • Clears all cached user data
  • Stops active trip monitoring
  • User will need to re-authenticate for subsequent operations

Implementation

Future<void> logout() async {
  try {
    await kruzr_comm.logout();
    return;
  } on PlatformException catch (e) {
    if (kDebugMode) {
      print(e);
      print("PlatformException in logout");
    }
    return Future.error("Unable to logout user");
  } on Exception catch (e) {
    if (kDebugMode) {
      print(e);
      print("Exception in logout");
    }
    return Future.error("Unable to logout user");
  }
}