Closed Cteq3132 closed 2 months ago
Hello @Cteq3132, thanks again for bringing up this topic! I'm currently hesitant to introduce the equatable dependency to the SDK because the amount of dependencies should be kept at a minimum. However, let's discuss this potential change. Could you explain your use case for the comparison?
Would it be possible to implement a custom class that extends equatable on your app level? For example this is what I thought about:
class EquatablePaymentAdvancedFinished extends Equatable {
final PaymentAdvancedFinished paymentAdvancedFinished;
const EquatablePaymentAdvancedFinished(
{required this.paymentAdvancedFinished});
@override
List<Object?> get props => [paymentAdvancedFinished.resultCode];
}
And then mapping the payment result
if (paymentResult is PaymentAdvancedFinished) {
final EquatablePaymentAdvancedFinished equatablePaymentAdvancedFinished =
EquatablePaymentAdvancedFinished(paymentAdvancedFinished: paymentResult);
}
This would be the corresponding test:
test("Equatable test", () {
final resultA = PaymentAdvancedFinished(resultCode: "Accepted");
final resultB = PaymentAdvancedFinished(resultCode: "Accepted");
final nonEquatable = resultA == resultB;
expect(nonEquatable, false);
final resultC = EquatablePaymentAdvancedFinished(paymentAdvancedFinished: resultA);
final resultD = EquatablePaymentAdvancedFinished(paymentAdvancedFinished: resultB);
final equatable = resultC == resultD;
expect(equatable, true);
});
Please let me know if this might be a solution for introducing equatable for you.
Hi @Cteq3132, we will close this issue. Please feel free to open it again, if you have any additional questions.
Describe the bug The class
PaymentResult
and all its implementation are not comparable. In Flutter, classes must extend Equatable to be able to compare object between them. Not doing so produces the following result:To Reproduce See above.
Expected behavior Class comparison implementation.
Screenshots /
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.