getUserId method

  1. @override
Future<Either<Failure, String>> getUserId()
override

Implementation

@override
Future<Either<Failure, String>> getUserId() async {
  try {
    if (userId?.isEmpty ?? false) {
      var result = await userDetailsRepo.getUserID();
      result.fold((l) => null, (r) {
        userId = r;
      });
      if (result.isRight()) {
        var rightResult = result.fold((l) => null, (r) => r);
        return Right(rightResult ?? "");
      } else {
        return Left(GetUserIDFailure());
      }
    } else {
      return Right(userId!);
    }
  } catch (e) {
    return Left(GetUserIDFailure());
  }
}