revenuecat 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

Deprecated - Please use official lib #

This is not an official RevenueCat library. When this was created, RevenueCat did not have official support for Flutter yet. The good news is that they do support Flutter now. Please use the official lib instead.

I have no plans of maintaining this project.

Install #

Plugin is published on Pub. Add this to your pubspec.yaml:

  revenuecat: ^1.0.4

Then run

flutter packages get

Import it in your dart files

import 'package:revenuecat/revenuecat.dart';

How to use #

  1. Go over to RevenueCat and create an account. Understand what Entitlements are and create the ones you need.

  2. Initialize the plugin

await RevenueCat.setup("YOUR_API_KEY_HERE", null);

If you have user accounts, the second parameter should be the user id. Leaving that null makes RevenueCat generate ids for you. Read more in the docs

  1. Know if the user is paying

This bit is async. You need to listen for changes to the Purchaser Info and find a way to update the app UI to reflect locked/unlocked features.


We recommend you do this at the highest level in your app and find a way to propagate this info. We use an InheritedWidget to keep this state and listen for changes in another "blocker" widget that updates when the InheritedWidget changes state. The "blocker" widget blocks access to whatever is below it and shows a "PRO" badge on top. This is approach is simplistic but effective, and works for us.

Bottom line is you need to listen for state changes from RevenueCat. Listener structure is found here.

  1. Get the Entitlements
var entitlements = await RevenueCat.getEntitlements();

Response is a Map with Entitlements, which then contain Offerings, which contain Products. Products contain price, period, introductory price, etc. It's best to look at the models directly to understand more.

  1. Display Products, start payment flow
await RevenueCat.makePurchase(product.identifier);
  1. RevenueCat will take care of the rest and update your listeners from number 3

License #

Published under MIT License. Read it here

1.0.5 #

1.0.3 #

  • Fixed Android problems

1.0.2 #

  • Fixed Android problems

1.0.1 #

  • Updated to iOS 1.2.1 and Android 1.4.2
  • Refactored iOS and Android to use singleton instance of RC

0.0.1 #

  • Initial version, works with iOS and Android subscriptions


import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:revenuecat/revenuecat.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      await RevenueCat.setup("YOUR_API_KEY_HERE", null);
      var entitlements = await RevenueCat.getEntitlements();
      print("Entitlements are $entitlements");
      var products = await RevenueCat.getProducts(["com.postmuseapp.designer.sub.monthly"]);
      print("Products are $products");
      platformVersion = await RevenueCat.getAppUserID();
    } catch (e, s) {
      platformVersion = 'Failed with $e $s';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('RevenueCat example app'),
        body: new Center(
          child: new Text('RevenueCat user id: $_platformVersion\n'),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  revenuecat: ^1.0.5

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:revenuecat/revenuecat.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/revenuecat.dart. (-1.99 points)

Analysis of lib/revenuecat.dart reported 4 hints:

line 7 col 57: 'PurchaserInfo' is deprecated and shouldn't be used. Please use purchases_flutter library instead of this.

line 7 col 86: 'PurchasesError' is deprecated and shouldn't be used. Please use purchases_flutter library instead of this.

line 11 col 32: 'PurchaserInfo' is deprecated and shouldn't be used. Please use purchases_flutter library instead of this.

line 11 col 61: 'PurchasesError' is deprecated and shouldn't be used. Please use purchases_flutter library instead of this.

Maintenance suggestions

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8