mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-29 09:11:17 +01:00
fix(paywall): "Go Pro" from the trainer picker opens instead of crashing
The onboarding trainer picker passed the State's own context into connectTrainerFromPicker. Its trial gate opens the Go Pro dialog, whose purchase action opens the paywall drawer -- and that context sits above the Scaffold's DrawerOverlay, so openDrawer's `parentLayer!` threw. In release the user saw only a "Null check operator used on a null value" toast and the paywall never appeared, which on an expired trial leaves no way forward at all. Pass _sheetContext, which lives below the Scaffold. _showPaywall also stops depending on callers getting that right: with no DrawerOverlay ancestor it now falls back to showDialog, which only needs a Navigator. The paywall already constrains and scrolls itself, so it renders correctly either way. The paywall is the last thing that should break when a caller passes the wrong context. Symbolized from a support bundle (chat 197d1f1a, Windows 6.4.3 patch 13): four identical traces seconds apart, each on the Go Pro tap. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -579,7 +579,11 @@ class _OnboardingPageState extends State<OnboardingPage> {
|
||||
/// of ConnectionCard._onSelect (proxy_device_details/connection_card.dart);
|
||||
/// the details page stays reachable from the home screen for mode changes.
|
||||
Future<void> _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(() {});
|
||||
}
|
||||
|
||||
|
||||
@@ -341,6 +341,20 @@ class IAPManager {
|
||||
}
|
||||
|
||||
Future<void> _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<void>(
|
||||
context: context,
|
||||
builder: (c) => Paywall(defaultToFullVersion: !subscription),
|
||||
);
|
||||
return;
|
||||
}
|
||||
openDrawer(
|
||||
context: context,
|
||||
// The paywall scrolls, which swallows the drawer's own swipe-to-close —
|
||||
|
||||
Reference in New Issue
Block a user