logOut method

  1. @override
Future<void> logOut()
override

Logs out the current user via HTTP POST request.

This method sends a POST request to the logout endpoint to end the user's session. It uses the stored email and password for authentication.

Returns:

  • A Future that completes when the logout operation is successful

Throws:

  • Exception if the logout fails or returns a non-success status

Example:

try {
  await authSource.logOut();
  jdRepoConsole("Successfully logged out");
} catch (e) {
  jdRepoConsole("Logout failed: $e");
}

Implementation

@override
Future<void> logOut() async {
  var result = await HttpClient(userToken: true).sendRequest(
      method: HttpMethod.POST,
      url: "$baseUrl/$logoutUrl",
      body: {"email": email , "password": pass},
      cancelToken: CancelToken());

  if (result.data!.status != StatusModel.success) {
    throw Exception(result.data!.message);
  }
}