IapFailure class
Represents a purchase failure with detailed information.
Provides convenience methods to determine how to handle the failure:
result.onFailure((failure) {
if (failure.shouldIgnore) return; // User cancelled, etc.
if (failure.canRetry) {
showRetryButton();
} else {
showError(failure.displayMessage);
}
});
Constructors
- IapFailure({required String code, required String message, String? hint, bool isCancelled = false, Object? originalError})
-
const
- IapFailure.cancelled({String code = 'cancelled', String message = 'Purchase was cancelled', String? hint})
-
Creates a cancelled failure.
const
Properties
- canRetry → bool
-
Whether the user can retry the purchase.
no setter
- code → String
-
Error code for programmatic handling.
final
- displayMessage → String
-
User-friendly message suitable for display.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String?
-
Hint for resolving the error (optional).
final
- isCancelled → bool
-
Whether the user cancelled the purchase.
final
- isConfigurationError → bool
-
Whether this is a configuration error (developer issue).
no setter
- isNetworkError → bool
-
Whether this is a network-related error.
no setter
- message → String
-
Human-readable error message.
final
- originalError → Object?
-
Original exception (if available).
final
- requiresUserAction → bool
-
Whether the user needs to take action (e.g., payment method issue).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldIgnore → bool
-
Whether this error can be safely ignored (user-initiated cancellation).
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited