getUser method

Future<User?> getUser({
  1. required String userName,
  2. required String hashedPassword,
})

Logs in a user and retrieves their user data if the login is successful.

This method sends a login request to the API and returns a User object if the login is successful. If the login fails, it returns null.

  • userName: The user's login identifier.
  • hashedPassword: The user's hashed password.

Returns a User object if the login is successful, or null if it fails.

Implementation

Future<User?> getUser({
  required String userName,
  required String hashedPassword,
}) async {
  ApiReturn apiResponse = await _apiConnector.getUserRepo().login(
    userName: userName,
    hashedPassword: hashedPassword,
  );
  if (!apiResponse.success) {
    return null;
  } else {
    return apiResponse.data as User;
  }
}