ApplePayButton class

Shows the Apple Pay payment sheet to the user.

This line triggers the pay plugin to display the Apple Pay payment UI, using the configuration and payment items provided.

Internally, it calls the showPaymentSelector() method from the Pay class, which:

  • Opens the Apple Pay interface (on iOS)
  • Uses the payment details defined in paymentItems
  • Returns the result of the transaction (such as success, failure, or cancellation)

Parameters:

  • PayProvider.flutter_pay_buttons: Tells the plugin to use Apple Pay as the payment method.
  • widget.paymentItems: A list of items showing what the user is paying for (e.g., product names, totals).

Example of what's happening:

final result = await _pay.showPaymentSelector(
  PayProvider.flutter_pay_buttons,
  [
    PaymentItem(label: 'Total', amount: '49.99'),
  ],
);

Result:

The result is a Map<String, dynamic> containing information about the outcome of the payment. It's passed to the onPaymentResult() callback:

widget.onPaymentResult(result);

A customizable Apple Pay button widget integrated with the pay plugin.

This widget displays an Apple Pay button that triggers the Apple Pay payment sheet when tapped. It provides configuration options for merchant details, supported networks, currencies, billing/shipping requirements, and styling.

Inheritance

Constructors

ApplePayButton({Key? key, double? height, double? width, EdgeInsets? margin, Color? backgroundColor, double? cornersRadius, required String merchantId, required String merchantName, required String amount, List<String>? merchantCapabilities, List<String>? supportedNetworks, String? countryCode, String? currencyCode, required List<PaymentItem> paymentItems, List<String>? requiredBillingContactFields, List<String>? requiredShippingContactFields, required FutureOr<void> onPaymentResult(Map<String, dynamic> result), MainAxisSize mainAxisSize = MainAxisSize.min, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, Widget? child})
const

Properties

amount → String
Total amount for the transaction (for reference only; actual items are in paymentItems).
final
backgroundColor → Color?
Background color of the button.
final
child → Widget?
Custom widget to replace the default Apple Pay button UI.
final
cornersRadius → double?
Corner radius for rounded button edges.
final
countryCode → String?
Country code (e.g., "US", "PK").
final
currencyCode → String?
Currency code (e.g., "USD", "EUR").
final
hashCode → int
The hash code for this object.
no setterinherited
height → double?
Height of the Apple Pay button.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
mainAxisAlignment → MainAxisAlignment
How child widgets are aligned horizontally inside the button.
final
mainAxisSize → MainAxisSize
Determines how much horizontal space the button’s Row takes up.
final
margin → EdgeInsets?
External spacing (margin) around the button.
final
merchantCapabilities → List<String>?
Capabilities supported by the merchant (e.g., 3DS, debit, credit).
final
merchantId → String
Apple Pay merchant identifier (issued by Apple).
final
merchantName → String
Display name of the merchant shown in Apple Pay sheet.
final
onPaymentResult → FutureOr<void> Function(Map<String, dynamic> result)
Callback invoked when Apple Pay returns a payment result.
final
paymentItems → List<PaymentItem>
List of payment items shown in the Apple Pay sheet.
final
requiredBillingContactFields → List<String>?
Required billing contact fields (e.g., name, postalAddress, phone).
final
requiredShippingContactFields → List<String>?
Required shipping contact fields (e.g., postalAddress, name).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportedNetworks → List<String>?
Supported card networks (e.g., visa, amex, masterCard).
final
width → double?
Width of the Apple Pay button.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ApplePayButton>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited