Matthias Nott
2026-04-01 b6df48ad4ba8be779a4ae233382f248a53f18068
fix: default isPro=true for dev builds, graceful StoreKit unavailable handling
2 files modified
changed files
lib/providers/providers.dart patch | view | blame | history
lib/services/purchase_service.dart patch | view | blame | history
lib/providers/providers.dart
....@@ -1,5 +1,6 @@
11 import 'dart:convert';
22
3
+import 'package:flutter/foundation.dart';
34 import 'package:flutter/material.dart';
45 import 'package:flutter_riverpod/flutter_riverpod.dart';
56 import 'package:flutter_secure_storage/flutter_secure_storage.dart';
....@@ -215,5 +216,6 @@
215216 // --- Pro / Purchase Status ---
216217
217218 /// Whether the user has purchased PAILot Pro (full access).
218
-/// Updated by PurchaseService after StoreKit verification.
219
-final isProProvider = StateProvider<bool>((ref) => false);
219
+/// Defaults to true — PurchaseService sets to false after StoreKit verification
220
+/// confirms no purchase. This way dev/sideloaded builds work without IAP.
221
+final isProProvider = StateProvider<bool>((ref) => true);
lib/services/purchase_service.dart
....@@ -52,10 +52,20 @@
5252 /// Initialize the service. Call once at app startup.
5353 Future<void> initialize() async {
5454 // Restore cached value immediately so UI doesn't flicker.
55
+ // Default to true for dev/sideloaded builds (no StoreKit configured).
5556 final prefs = await SharedPreferences.getInstance();
56
- _isPro = prefs.getBool(_kProCacheKey) ?? false;
57
+ _isPro = prefs.getBool(_kProCacheKey) ?? true;
5758 notifyListeners();
5859
60
+ // Check if IAP is available — may not be on dev/sideloaded builds
61
+ final available = await InAppPurchase.instance.isAvailable();
62
+ if (!available) {
63
+ debugPrint('[IAP] StoreKit not available — assuming pro (dev build)');
64
+ _isPro = true;
65
+ notifyListeners();
66
+ return;
67
+ }
68
+
5969 // Listen for ongoing purchase updates.
6070 final purchaseUpdated = InAppPurchase.instance.purchaseStream;
6171 _subscription = purchaseUpdated.listen(