Introduction
Implementing in-app purchases in Flutter can be complex, but integrating RevenueCat streamlines subscription management, cross-platform receipt validation, and analytics. RevenueCat’s Flutter SDK wraps the StoreKit and Billing APIs, handling entitlements, promotions, and restore flows for you. In this tutorial, you’ll learn how to set up RevenueCat for Flutter, fetch products, make in-app purchases, and handle entitlement updates.
Configuring RevenueCat SDK
Add the dependency in pubspec.yaml:
dependencies:
purchases_flutter
Initialize RevenueCat in your main.dart before runApp():
import 'package:purchases_flutter/purchases_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Purchases.configure(PurchasesConfiguration("public_sdk_key"));
runApp(MyApp());
}Replace "public_sdk_key" with your RevenueCat API key from the dashboard. This single call handles observer registration for both iOS and Android.
Enable in-app purchases in Xcode (App Store Connect) and Google Play Console. Define consumable, non-consumable, or subscription products there, matching identifiers in RevenueCat.
Fetching Products and Enabling Purchases
After initialization, retrieve product offerings configured in the RevenueCat dashboard. Offerings let you group different SKUs under identifiers (e.g., "monthly", "yearly").
class PurchaseService {
Future<Offerings> fetchOfferings() async {
try {
return await Purchases.getOfferings();
} catch (e) {
rethrow;
}
}
Future<void> buyProduct(Package package) async {
try {
await Purchases.purchasePackage(package);
} on PurchasesErrorCode catch (error) {
print("Purchase failed: ${error.message}");
}
}
}In your UI layer:
final service = PurchaseService();
final offerings = await service.fetchOfferings();
final monthly = offerings.current?.monthly;
ElevatedButton(
onPressed: monthly == null
? null
: () => service.buyProduct(monthly),
child: Text("Subscribe Monthly"),
);This code fetches your configured offerings and launches a purchase flow when the user taps a button.
Listening to Entitlements and Restoring Purchases
RevenueCat emits entitlement updates whenever a purchase or restore succeeds. You can listen globally:
class EntitlementManager {
EntitlementManager() {
Purchases.addCustomerInfoUpdateListener(_onCustomerInfo);
}
void _onCustomerInfo(CustomerInfo info) {
final premium = info.entitlements.all["premium"];
if (premium?.isActive == true) {
} else {
}
}
Future<void> restorePurchases() async {
try {
await Purchases.restoreTransactions();
} catch (e) {
print("Restore failed: $e");
}
}
}Call EntitlementManager() early in your app lifecycle (e.g., in a provider or state management init). Expose restorePurchases() in your settings or purchase screen to let users recover purchases.
Best Practices and Edge Cases
• Validate SKU identifiers in RevenueCat against those in your store consoles.
• Use Offerings for A/B tests or region-specific pricing without code changes.
• Handle PurchasePendingError if the transaction requires external approval (e.g., family sharing).
• Monitor revenue and cancellation metrics directly in RevenueCat’s dashboard.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
With RevenueCat integrated, your Flutter app’s in-app purchase life cycle—from product display to receipt validation and restoration—is abstracted into a few lines of code. You no longer manage platform-specific boilerplate or server-side receipt verification manually. Now you’re equipped to implement in-app purchases, subscriptions, and entitlements in your Flutter projects with confidence. Happy coding!