Skip to main content
Skip to navigation

Flutter

Instructions for installing the RevenueCat SDK for Flutter

AIAsk AIChatGPTClaude

This tutorial shows you how to install the RevenueCat SDK in your Flutter app. By the end, you'll have the SDK added to your project with pub, verified with a successful build, and be ready to configure the SDK.

Prerequisites

You need the following before you start:

1. Install the SDK

Release

The SDK ships as the purchases_flutter package. Install purchases_ui_flutter alongside it for UI components like Paywalls and Customer Center.

  1. Add both packages:
flutter pub add purchases_flutter purchases_ui_flutter

Alternatively, declare the dependencies in your pubspec.yaml and run flutter pub get:

dependencies:
purchases_flutter: ^10.10.0
purchases_ui_flutter: ^10.10.0

2. Import the SDK

  1. Add the import to any source file that uses the SDK:
import 'package:purchases_flutter/purchases_flutter.dart';
  1. Run the app (flutter run). If the app builds and launches with the import in place, the SDK is installed correctly.

Additional iOS setup

New Flutter projects resolve the SDK's iOS native dependencies with Swift Package Manager automatically the first time you build, so there's nothing extra to configure.

Using CocoaPods for iOS?

If your project installs iOS dependencies with CocoaPods instead of Swift Package Manager, check two things in your ios/ folder:

  • iOS deployment target. RevenueCat requires iOS 13.0 or higher, and Flutter does not automatically set the deployment target for your project. Edit ios/Podfile and add the following line if it's not already there, set to 13.0 or higher:
platform :ios, '13.0'
  • Swift version. RevenueCat requires Swift 5.0 or higher. If the Podfile in your project's ios folder specifies a Swift version, make sure it's at least 5.0, otherwise you may run into build issues.

When you're ready to distribute on the App Store, enable the In-App Purchase capability in Xcode — see the iOS install guide. Nothing else is needed to build and test with the Test Store.

Additional Android setup

Set your Activity's launchMode

Depending on your user's payment method, Google Play may ask them to verify the purchase in another app, such as their banking app. This means they have to background your app during the purchase, and backgrounding your app cancels the purchase if launchMode is set to anything other than standard or singleTop.

New Flutter projects set the main Activity's launchMode to singleTop, which is safe.

In android/app/src/main/AndroidManifest.xml, verify that the launchMode of the Activity that triggers purchases is standard or singleTop:

<activity
android:name="com.your.Activity"
android:launchMode="standard" /> <!-- or singleTop -->

For details on the options, see Android's launchMode documentation.

Subclass FlutterFragmentActivity

RevenueCat Paywalls require your MainActivity to subclass FlutterFragmentActivity instead of FlutterActivity:

package com.your.package.name

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity()

Flutter Web

RevenueCat's Flutter SDK supports web platforms, allowing you to manage subscriptions across Flutter web, mobile, and desktop apps using the same SDK.

Web product configuration

On web, the Flutter SDK supports the same billing engines as the Web SDK: RevenueCat Billing, Stripe Billing, and Paddle Billing. Your billing engine determines where products, taxes, emails, and subscription management are configured.

To enable web purchases in your Flutter app, connect a billing engine and create a web config for it:

Then configure the SDK in your Flutter app using the public API key of the web config you created.

📘Web purchases vs In-App Purchases

Web purchases are separate from iOS/Android in-app purchases, but integrate with the same RevenueCat entitlements system, allowing unified subscription management across platforms.

Current limitations

When using the Flutter SDK on web, keep in mind the following:

  • Billing engine required: Web purchases require a RevenueCat Billing, Stripe Billing, or Paddle Billing setup. Native iOS/Android in-app purchases cannot be processed through the web platform.
  • Payment processing: RevenueCat Billing uses Stripe as the payment processor. With Stripe Billing, payments go through Stripe Checkout, and with Paddle Billing through Paddle's checkout.
  • Subscription management: RevenueCat Billing subscriptions can be managed through the RevenueCat-provided Customer Portal. Stripe Billing and Paddle Billing subscriptions are managed in Stripe and Paddle respectively.
  • Platform separation: Web products must be configured separately from iOS/Android products, though entitlements can be shared across platforms.
  • User identity: For unified cross-platform subscriptions, ensure you're using the same appUserID across web and mobile platforms.
  • RevenueCat Paywalls: Presenting RevenueCat Paywalls (presentPaywall) is not yet supported on web.
  • Unsupported operations: There are some unsupported operations. Mainly operations getProducts, purchaseProduct or restorePurchases won't work on web environments.

Troubleshooting

Type conflicts with other plugins

If you're using other plugins like mobx, you may run into conflicts with types from other plugins having the same name as those defined in purchases_flutter. If this happens, you can resolve the ambiguity in the types by adding an import alias, for example:

import 'package:purchases_flutter/purchases_flutter.dart' as purchases;

After that, you can reference the types from purchases_flutter as purchases.Foo, like purchases.CustomerInfo.

Next steps

You've installed the RevenueCat SDK and verified your project builds.

  • Configure the SDK with your project's API key — the next step in the Quickstart.
  • Testing without an App Store or Google Play setup? Purchases work out of the box with the Test Store.
Was this page helpful?