getUserById method

  1. @override
Future<Either<Failure, User>> getUserById(
  1. int id
)
override

Implementation

@override
Future<Either<Failure, User>> getUserById(int id) async {
  final result = await _gateway.getUserById(id);
  return result.fold(
    Left.new,
      (json) {
        try{
          final user = User.fromJson(json);
          return Right(user);
        }catch(e, stackTrace){
          return Left(
            Failure(
              title: 'Error en el UserRepositoryImpl',
              code: 'mapping_error',
              description: "Error al mapear el usuario obtenido por id ",
              stackTrace: stackTrace.toString(),
              type: FailureSeverity.blocking
            )
          );
        }
      }
  );

}