| 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 @@ 1 1 import 'dart:convert'; 2 2 3 +import 'package:flutter/foundation.dart';3 4 import 'package:flutter/material.dart'; 4 5 import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 6 import 'package:flutter_secure_storage/flutter_secure_storage.dart'; .. .. @@ -215,5 +216,6 @@ 215 216 // --- Pro / Purchase Status --- 216 217 217 218 /// 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 verification220 +/// 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 @@ 52 52 /// Initialize the service. Call once at app startup. 53 53 Future<void> initialize() async { 54 54 // Restore cached value immediately so UI doesn't flicker. 55 + // Default to true for dev/sideloaded builds (no StoreKit configured).55 56 final prefs = await SharedPreferences.getInstance(); 56 - _isPro = prefs.getBool(_kProCacheKey) ?? false;57 + _isPro = prefs.getBool(_kProCacheKey) ?? true;57 58 notifyListeners(); 58 59 60 + // Check if IAP is available — may not be on dev/sideloaded builds61 + 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 +59 69 // Listen for ongoing purchase updates. 60 70 final purchaseUpdated = InAppPurchase.instance.purchaseStream; 61 71 _subscription = purchaseUpdated.listen(