revenuecat 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new53

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.

Install

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

dependencies:
  revenuecat: ^0.0.3

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

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: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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';
  
Version Uploaded Documentation Archive
0.0.3 Nov 9, 2018 Go to the documentation of revenuecat 0.0.3 Download revenuecat 0.0.3 archive
0.0.2 Nov 9, 2018 Go to the documentation of revenuecat 0.0.2 Download revenuecat 0.0.2 archive
0.0.1 Nov 9, 2018 Go to the documentation of revenuecat 0.0.1 Download revenuecat 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
18
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

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

Analysis of lib/revenuecat.dart reported 1 hint:

line 2 col 8: Unused import: 'dart:ui'.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

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