Skip to content

Fix Google Pay button not rendering (register view factory + race fix) [2.0.1]#10

Open
flitt-sdk-developers wants to merge 3 commits into
flittpayments:mainfrom
flitt-sdk-developers:fix/gpay-button-race-2.0.1
Open

Fix Google Pay button not rendering (register view factory + race fix) [2.0.1]#10
flitt-sdk-developers wants to merge 3 commits into
flittpayments:mainfrom
flitt-sdk-developers:fix/gpay-button-race-2.0.1

Conversation

@flitt-sdk-developers

@flitt-sdk-developers flitt-sdk-developers commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Makes the GooglePayButton widget render. Two independent, confirmed root causes:

  1. Platform view was never registered. The google_pay_button_view PlatformViewFactory was registered only inside GooglePayButtonPlugin, which is never added to the engine (pubspec declares FlittMobilePlugin as the sole pluginClass, so GeneratedPluginRegistrant loads only that). The view type was therefore unregistered and the widget could never create its native view. Fixed by registering the factory from FlittMobilePlugin.onAttachedToEngine.

  2. Race condition on config load. build() gated the native view on the fast native support check only, so when it won the race against the slower payment-config fetch, the view was created with allowedPaymentMethods == null; the subsequent _viewKey = UniqueKey() reset then destroyed/recreated the legacy Virtual-Display AndroidView, leaving the button blank. Fixed by gating on supportsGPay && config != null and dropping the _viewKey reset — the view is created once with valid config.

Changes

  • android/.../FlittMobilePlugin.java: register google_pay_button_view; GooglePayButtonFactory made public.
  • lib/src/google_pay_button.dart: gate view creation on supportsGPay && config != null; remove the _viewKey reset.
  • example/.../MainActivity.java: moved to the directory matching its declared package.
  • CHANGELOG.md / pubspec.yaml: 2.0.1.

Backward compatibility

No public API change. Drop-in flutter pub get.

Verification

  • flutter analyze / flutter pub get clean.
  • On a real Android device signed into Google Pay, token-based flow: button renders on first appearance across repeated launches; tap → googlePayToken → 3DS → onSuccess.
  • Reminder: the app must declare com.google.android.gms:play-services-wallet:19.4.0+ and the com.google.android.gms.wallet.api.enabled=true manifest flag.

🤖 Generated with Claude Code

flitt-sdk-developers and others added 2 commits July 9, 2026 19:18
The native Google Pay AndroidView was gated on the fast native support
check only, so when it resolved before the slower payment-config fetch,
the platform view was created with allowedPaymentMethods == null. The
subsequent config load then reset _viewKey to a new UniqueKey(),
destroying and recreating the legacy Virtual-Display AndroidView and
leaving the button blank.

Gate the view on `supportsGPay && config != null` and drop the _viewKey
reset in _initializeCloudipsp(), so the platform view is created exactly
once with valid config, independent of async completion order.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The platform view factory for "google_pay_button_view" was registered
only inside GooglePayButtonPlugin, which is never added to the Flutter
engine: pubspec declares FlittMobilePlugin as the sole pluginClass, so
GeneratedPluginRegistrant only loads FlittMobilePlugin. As a result the
view type was never registered and any GooglePayButton widget failed to
create its native view — without this the race fix alone still cannot
render the button.

Register the factory from FlittMobilePlugin.onAttachedToEngine (the plugin
that is actually loaded) and expose GooglePayButtonFactory for it. Also
move the example MainActivity to the directory matching its declared
package (com.flitt.mobile_example).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@flitt-sdk-developers
flitt-sdk-developers force-pushed the fix/gpay-button-race-2.0.1 branch from 3da6ca8 to e50ee15 Compare July 9, 2026 16:20
- Google Pay button: the native side now converts the Dart logical-pixel (dp)
  width/height to physical pixels before applying LayoutParams, so the button
  renders at its full brand-guide height instead of a ~16dp strip. It fills the
  host width, is centered, and the Dart widget clamps the height to a 48dp
  minimum.
- Release: merge the 2.0.2 and 2.0.3 notes into a single 2.0.1 CHANGELOG entry
  and keep pubspec at 2.0.1.
- Example: migrate the Android build scripts to the Kotlin DSL, modernize the
  toolchain, apply the Flitt rebrand (entitlement, currency), and refresh the
  example app (standalone Google Pay screen).
- Tests: refresh expired test-card expiry dates (2025 -> 2035) and align the
  merchantId construction test with the deferred (payment-time) validation
  behavior. Full suite is green (107 passing).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant