execute method Null safety

  1. @override
Future<Either<Failure, PaymentCard>> execute(
  1. EditCardParams params
)
override

Execute the use case and return a Failure when an error has occurred and the PaymentCard is the card is saved

Implementation

@override
Future<Either<Failure, PaymentCard>> execute(EditCardParams params) async {
  try {
    var userId = await getUserId();
    var card = await repository.updateCard(userId, params.card);
    return Right(card);
  } on CacheException {
    return Left(CacheFailure("cannotGetUser"));
  } on Exception {
    return Left(ServerFailure("cannotSaveCard"));
  }
}