RevenueCat Flutter Integration: Entitlements to Paywall

· 5 min read

In-app purchases are fiddly: two stores with different billing systems, receipts to validate, subscriptions that renew, lapse and recover. RevenueCat wraps that in one SDK and one dashboard, and many Flutter apps use it. This page is a practical integration guide with Claude Code: the concepts, the code and what to check. It uses RevenueCat’s documentation, read on the day this post was written. The store rules still apply however you integrate: see guideline 3.1.1 and the Google Play payments policy.

The concepts

  • Products are the things you sell, configured in each store and imported into RevenueCat.
  • Entitlements “represent a level of access, features, or content that a user is ‘entitled’ to.” They “are used to ensure a user has appropriate access to content based on their purchases, without having to manage all of the product identifiers in your app code.” Most apps have one, such as pro. You create an entitlement, then attach products to it, so RevenueCat knows what to unlock after each purchase.
  • Offerings are “a way to group products together to display to users”. RevenueCat suggests thinking of them as a paywall that contains a set of products. Each offering holds packages.

The design point: your app code checks an entitlement, not a product ID. Adding a new annual plan later does not change your app logic.

Install

RevenueCat’s Flutter page says the SDK ships as purchases_flutter, with purchases_ui_flutter for UI components:

flutter pub add purchases_flutter purchases_ui_flutter

and you import it with import 'package:purchases_flutter/purchases_flutter.dart';. It also notes that if another plugin defines types with the same names, you can import with a prefix to resolve the ambiguity.

Configure

RevenueCat’s quickstart says to initialise Purchases with your public API key, one per platform, once at startup. Keep the keys per environment. MobileKit passes per-flavor values, including the purchase keys, in git-ignored config files with committed examples, so a development build uses the sandbox project’s keys and a release build the production ones. Never put a secret key in the app: only the public SDK key belongs there.

Make a purchase

RevenueCat’s Flutter example fetches an offering’s package and purchases it, then checks the entitlement on the result:

try {
  final purchaseParams = PurchaseParams.package(package);
  PurchaseResult result = await Purchases.purchase(purchaseParams);
  if (result.customerInfo.entitlements.all["my_entitlement_identifier"]?.isActive ?? false) {
    // Unlock the pro content
  }
} on PlatformException catch (e) {
  var errorCode = PurchasesErrorHelper.getErrorCode(e);
  if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
    showError(e);
  }
}

Two details worth copying from that example:

  • Check the entitlement, not the product.
  • Treat “cancelled” as not an error. If the user backs out, return quietly to the paywall without an error message.

Customer info and restore

RevenueCat’s customer info object “is updated whenever a purchase or restore occurs and periodically throughout the lifecycle of your app.” Entitlements are cached, so users keep access without a connection: the documentation says the SDK updates the cache if it is older than five minutes, when you call for customer info.

“It is recommended that all apps have some way for users to trigger the restorePurchases method, even if you require all customers to create accounts.” Put a Restore purchases button on the paywall and in settings. That also meets the stores’ expectation for restorable purchases.

Test without real money

RevenueCat’s sandbox page describes two ways: the Test Store, a built-in environment that “works immediately without platform setup” and needs no store accounts, and the platform sandboxes from Apple and Google, for testing real store integrations. Use the Test Store to build the flow, then test on both stores’ sandboxes before release, including buy, restore, cancel, expire and a failed payment. See mobile app paywall design for the states to cover.

Model access in your app

A clean pattern, in MobileKit’s Flutter standards:

  • Wrap the purchases SDK in a repository, so widgets never call it directly.
  • Expose a single “is pro” value from state that is kept alive for the whole app, because it is app-wide.
  • Define the rule once. For example, the Santa Radar run unlocked pro for a lifetime purchase or for a seasonal pass that expired on a fixed date, and the same rule ran in the app and on the server.
  • For features that cost you money, such as AI calls, also check the entitlement on the server, not just in the app. A local flag a user could flip is a security finding. See the mobile app security checklist.

See Riverpod with Claude Code for the state side.

Using Claude Code

Claude Code is good at this integration because the pattern is well documented. Give it the documentation page and ask it to:

  • add the dependency and a repository that wraps the SDK,
  • expose the entitlement state,
  • build the paywall states from your design, and
  • write tests that override the repository with a fake.

Do these steps yourself: creating the products in the stores and the dashboard, and entering API keys. An agent should not see them. Then run the sandbox tests on a real device.

Checklist

  • Products created in both stores and in RevenueCat
  • An entitlement with the products attached
  • Public keys per environment, no secret keys in the app
  • Purchase handles cancelled, failed and pending
  • Restore on the paywall and in settings
  • Entitlement checked on the server for costly features
  • Sandbox tests passed on both stores

The whole route is in Build a Flutter app with Claude Code.

Sources read on the day this post was written: RevenueCat: Flutter installation, RevenueCat: entitlements, RevenueCat: making purchases, RevenueCat: customer info and RevenueCat: sandbox testing.

Questions

What package do I install for RevenueCat in Flutter?

RevenueCat's documentation says the SDK ships as the purchases_flutter package, and that purchases_ui_flutter can be installed alongside it for UI components such as paywalls and Customer Center.

What is an entitlement?

RevenueCat describes an entitlement as a level of access, features or content that a user is entitled to, typically unlocked after they purchase a product. Most apps have only one, for example pro.

Do I need a restore purchases button?

RevenueCat recommends that all apps have some way for users to trigger restorePurchases, even if you require all customers to create accounts. Apple's guidelines also expect a restore mechanism.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.