From c22a92f0c74d94c56e337083c086d04187b2ed04 Mon Sep 17 00:00:00 2001 From: jonasbark Date: Sun, 25 Aug 2024 19:40:00 +0200 Subject: [PATCH] Fix https://github.com/flutter-stripe/flutter_stripe/issues/1861 (#1900) --- .../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