flutter_payments 0.1.5

  • README.md
  • Example
  • Installing
  • Versions
  • 85


Flutter In App Purchases For Humans.

pub package

Getting Started

This plugin makes it easy to make products or subscriptions for both Apple App Store and Google Play.


You can use the built-in SubscriptionManager which provides a Stream interface for purchase states and abstracts away most of the logic around subscription management. However, it does not perform extended validation of a Subscription, so it may be possible to inject an invalid Subscription depending on the platform and device security settings. It is recommended that you perform server-side validation of all purchases, if that is a concern.

SubscriptionManager Example

In App Purchases (Non-subscription Products)

You can run the included example app on an Android device to test the payment flow with test product SKUs.

Example App


Determine if Billing is available on the device.

final bool billingEnabled = await FlutterPayments.billingEnabled;


Fetch Product metadata from the store.

final List<Product> getProducts = await FlutterPayments.getProducts(
  skus: <String>[
  type: ProductType.InApp,


List<Purchase> purchase = await FlutterPayments.purchase(
  sku: 'android.test.purchased',
  type: ProductType.InApp,


Get the User's purchase history from the Store. Returns a list of Purchase instances.

final List<Purchase> purchaseHistory = await FlutterPayments.getPurchaseHistory(ProductType.InApp);
print('purchaseHistory: $purchaseHistory');

0.1.5 - Fix iOS

  • Fixed an error where channel got nuked in Swift code
  • Added purchase buttons to the SubscriptionManager example page
  • Added consumeToken for Android, still a WIP!

0.1.4 - Cleanup tasks, no library code changes.

  • Actually fix the JUnit 5 error in the build.gradle.

0.1.3 - Cleanup tasks, no library code changes.

  • Removed dead code from example app
  • Added docs to README

0.1.1 - Fixed bug SubscriptionManager

  • I made an error when copying SubscriptionManager over from my app :/

0.1.0 - Added SubscriptionManager

  • Added SubscriptionManager to make life easier for users
  • Updated example app to have buttons which trigger the Google Play sample SKUs
  • Updated Google Play error translation to use Dart exceptions :)
  • Other code cleanup tasks since apparently people found this.

0.0.2 - Bug fixes for Swift code

Fixed an error that caused the iOS plugin to forcefully eject occupants (aka an NPE).

0.0.1 - Initial release.

Releasing to make integration with my project easier, not for public consumption.


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

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

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

class _MyAppState extends State<MyApp> {
  List<String> logMessages = <String>[];

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Flutter Payments'),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: new Column(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Text('Products for Purchase'),
              buildPurchaseButton(context, 'android.test.canceled'),
              buildPurchaseButton(context, 'android.test.purchased'),
              buildPurchaseButton(context, 'android.test.item_unavailable'),
              Text('Log Messages'),

  Widget buildPurchaseButton(BuildContext context, String productSku) {
    return new RaisedButton(
      onPressed: () async {
        String message;
        try {
          final List<Purchase> list = await FlutterPayments.purchase(
            sku: productSku,
            type: ProductType.InApp,

          message = list.toString();
        } on FlutterPaymentsException catch (error) {
          message = error.toString();

        setState(() {
          logMessages.add('Purchase of "$productSku" result:\n$message');
      child: Text('Purchase "$productSku"'),

Use this package as a library

1. Depend on it

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

  flutter_payments: ^0.1.5

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:flutter_payments/flutter_payments.dart';
Version Uploaded Documentation Archive
0.1.5 Jul 13, 2018 Go to the documentation of flutter_payments 0.1.5 Download flutter_payments 0.1.5 archive
0.1.4 Jul 12, 2018 Go to the documentation of flutter_payments 0.1.4 Download flutter_payments 0.1.4 archive
0.1.3 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.3 Download flutter_payments 0.1.3 archive
0.1.2 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.2 Download flutter_payments 0.1.2 archive
0.1.1 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.1 Download flutter_payments 0.1.1 archive
0.1.0 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.0 Download flutter_payments 0.1.0 archive
0.0.2 Jul 8, 2018 Go to the documentation of flutter_payments 0.0.2 Download flutter_payments 0.0.2 archive
0.0.1 Jul 8, 2018 Go to the documentation of flutter_payments 0.0.1 Download flutter_payments 0.0.1 archive
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 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


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
url_launcher ^3.0.2 3.0.3 4.0.1
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
Dev dependencies
mockito ^2.2.3