Subscription and one-time purchase management via RevenueCat with Clean Architecture
IAP handles subscriptions and one-time purchases using RevenueCat. The starter kit provides a complete BLoC-based implementation. The app feature layer wraps the starter kit's IAP with app-specific logic.
starter-kit/SKILL.md)revenue_cat_api_key_android and revenue_cat_api_key_ios in env config (see skills/env-config/SKILL.md)The starter kit handles the IAP infrastructure:
starter_kit/lib/features/iap/
├── data/datasources/ # RevenueCat data source
├── domain/repositories/ # IAP repository interface
└── presentation/bloc/ # IapBloc with events/states
App-level wrapper (if needed):
features/iap/
├── iap_injector.dart
├── presentation/
│ ├── screens/
│ │ └── subscription_screen.dart
│ └── widgets/
│ └── product_card.dart
// Initialize (automatic with StarterKit)
StarterKit.iapBloc.add(const IapInitialize());
// Purchase a product
StarterKit.iapBloc.add(IapPurchaseProduct(productId: 'premium_monthly'));
// Restore purchases
StarterKit.iapBloc.add(const IapRestorePurchases());
// Listen to state
BlocListener<IapBloc, IapState>(
listener: (context, state) {
if (state is IapInitialized) {
final isSubscribed = state.subscriptionStatus.isActive;
final products = state.products;
}
},
)
final iapState = StarterKit.iapBloc.state;
if (iapState is IapInitialized) {
return iapState.subscriptionStatus.isActive;
}
return false;
To prevent RevenueCat classes from being stripped during release builds, keep rules are required. While the starter_kit package provides these automatically via consumerProguardFiles, it is highly recommended to also include them in your app's android/app/proguard-rules.pro for redundancy and visibility.
minifyEnabled true is set in your app's build.gradle.proguard-rules.pro:# RevenueCat Proguard Rules
-keep class com.revenuecat.purchases.** { *; }
-keep class com.revenuecat.purchases.ui.** { *; }
-keep class com.revenuecat.** { *; }
# Prevent obfuscation
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
StarterKit initializes RevenueCat using platform-specific API keys from EnvConfig.appUserId is automatically tied to the Firebase Auth UID.subscriptionStatus.isActive for the most reliable entitlement check.PaywallGate widget from starter_kit to wrap features that require premium. It handles the subscription check and shows the paywall if needed.Navigator.push(
context,
MaterialPageRoute(builder: (context) => const PaywallScreen()),
);
SettingsPanelScreen, the subscription section dynamically switches between "Go Pro" and "Manage Subscription" based on StarterKit.subscriptionManager.isPremium.IapBloc provided in widget tree