Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #235 #236

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions pay_ios/lib/src/widgets/apple_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class RawApplePayButton extends StatelessWidget {
}

/// A widget to draw the Apple Pay button through a [PlatforView].
class _UiKitApplePayButton extends StatelessWidget {
class _UiKitApplePayButton extends StatefulWidget {
dickermoshe marked this conversation as resolved.
Show resolved Hide resolved
static const buttonId = 'plugins.flutter.io/pay/apple_pay_button';

final VoidCallback? onPressed;
Expand All @@ -145,16 +145,21 @@ class _UiKitApplePayButton extends StatelessWidget {
this.type = ApplePayButtonType.plain,
});

@override
State<_UiKitApplePayButton> createState() => _UiKitApplePayButtonState();
}

class _UiKitApplePayButtonState extends State<_UiKitApplePayButton> {
@override
Widget build(BuildContext context) {
return UiKitView(
viewType: buttonId,
viewType: _UiKitApplePayButton.buttonId,
creationParamsCodec: const StandardMessageCodec(),
creationParams: {'style': style.enumString, 'type': type.enumString},
creationParams: {'style': widget.style.enumString, 'type': widget.type.enumString},
onPlatformViewCreated: (viewId) {
MethodChannel methodChannel = MethodChannel('$buttonId/$viewId');
MethodChannel methodChannel = MethodChannel('${_UiKitApplePayButton.buttonId}/$viewId');
methodChannel.setMethodCallHandler((call) async {
if (call.method == 'onPressed') onPressed?.call();
if (call.method == 'onPressed') widget.onPressed?.call();
});
},
);
Expand Down