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