revenuecat 1.0.4

RevenueCat Flutter plugin #

This is not an official RevenueCat repo. We use this plugin at PostMuse and decided to open source it. We welcome contributions of any kind. This implementation uses the native Android and iOS RevenueCat libraries.

This library uses native RevenueCat libraries 1.x.x, which means it does not yet use iOS and Android version 2.x.x - We are planning to update the library, but we also welcome pull requests if you want to be helpful.

Install #

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

dependencies:
  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.

RevenueCat.addPurchaseListener(purchaseListener);
RevenueCat.addPurchaserInfoUpdateListener(purchaserListener);
RevenueCat.addRestoreTransactionListener(purchaserListener);

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.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

example/README.md

revenuecat_example #

Demonstrates how to use the revenuecat plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  revenuecat: ^1.0.4

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/revenuecat.dart.

Run flutter format to format lib/revenuecat.dart.

Dependencies

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
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8

Admin