flutter_payments 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 33

flutter_payments #

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.

Subscriptions #

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

FlutterPayments.billingEnabled #

Determine if Billing is available on the device.

final bool billingEnabled = await FlutterPayments.billingEnabled;

FlutterPayments.getProducts #

Fetch Product metadata from the store.

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

FlutterPayments.purchase #

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

FlutterPayments.getPurchaseHistory #

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 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:flutter_payments/flutter_payments.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 Jan 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

83 out of 83 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/subscription_manager.dart. (-0.50 points)

Analysis of lib/src/subscription_manager.dart reported 1 hint:

line 41 col 17: This function has a return type of 'FutureOr

Format lib/src/dateutils.dart.

Run flutter format to format lib/src/dateutils.dart.

Format lib/src/plugin.dart.

Run flutter format to format lib/src/plugin.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/product.dart (Run flutter format to format lib/src/product.dart.)
  • lib/src/purchase.dart (Run flutter format to format lib/src/purchase.dart.)
  • lib/src/types.dart (Run flutter format to format lib/src/types.dart.)

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/pplante/flutter_payments was unreachable.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (url_launcher).

Package is getting outdated. (-52.05 points)

The package was last published 79 weeks ago.


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 5.4.1
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
Dev dependencies
mockito ^2.2.3