From cfce45495b434603f20384d577338e475c9e56fd Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Sun, 25 Aug 2024 13:52:06 +0200 Subject: [PATCH] Fix https://github.com/flutter-stripe/flutter_stripe/issues/1861 --- .../stripe/StripeSdkGooglePayButtonPlatformView.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkGooglePayButtonPlatformView.kt b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkGooglePayButtonPlatformView.kt index 6ee972944..b8d4c3e39 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkGooglePayButtonPlatformView.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkGooglePayButtonPlatformView.kt @@ -38,9 +38,6 @@ class StripeSdkGooglePayButtonPlatformView( googlePayButtonManager.borderRadius(payButton, creationParams["borderRadius"] as Int) } payButton.initialize() - payButton.getChildAt(0).setOnClickListener { - channel.invokeMethod("onPressed", null) - } } override fun getView(): View { @@ -53,5 +50,12 @@ class StripeSdkGooglePayButtonPlatformView( override fun onFlutterViewAttached(flutterView: View) { googlePayButtonManager.onAfterUpdateTransaction(payButton) + + // wait until view is attached to the view hierarchy + payButton.post { + (payButton.parent as View).setOnClickListener { + channel.invokeMethod("onPressed", null) + } + }; } } \ No newline at end of file