diff --git a/lib/pages/onboarding/onboarding_page.dart b/lib/pages/onboarding/onboarding_page.dart index 0160f8c6..cbd8866e 100644 --- a/lib/pages/onboarding/onboarding_page.dart +++ b/lib/pages/onboarding/onboarding_page.dart @@ -579,7 +579,11 @@ class _OnboardingPageState extends State { /// of ConnectionCard._onSelect (proxy_device_details/connection_card.dart); /// the details page stays reachable from the home screen for mode changes. Future _onPickTrainer(ProxyDevice device) async { - await connectTrainerFromPicker(context, device); + // _sheetContext, not context: the trial gate in connectTrainerFromPicker + // opens the Go Pro dialog, whose purchase action opens the paywall drawer. + // The State's own context sits above the Scaffold's DrawerOverlay, so that + // drawer died on a null check — see the note on [_sheetContext]. + await connectTrainerFromPicker(_sheetContext, device); if (mounted) setState(() {}); } diff --git a/lib/utils/iap/iap_manager.dart b/lib/utils/iap/iap_manager.dart index 5b3b1e4b..13afa154 100644 --- a/lib/utils/iap/iap_manager.dart +++ b/lib/utils/iap/iap_manager.dart @@ -341,6 +341,20 @@ class IAPManager { } Future _showPaywall(BuildContext context, bool subscription) async { + // openDrawer needs a DrawerOverlay ancestor (Scaffold creates one) and does + // `parentLayer!` in release, so a caller that hands us a context from above + // its own Scaffold turns "Go Pro" into a bare "Null check operator used on + // a null value" toast and the paywall never opens. Callers should pass a + // context below the Scaffold, but the paywall is the last thing that should + // break when one doesn't — fall back to a dialog, which only needs a + // Navigator. Paywall already constrains and scrolls itself. + if (DrawerOverlay.maybeFind(context) == null) { + await showDialog( + context: context, + builder: (c) => Paywall(defaultToFullVersion: !subscription), + ); + return; + } openDrawer( context: context, // The paywall scrolls, which swallows the drawer's own swipe-to-close —