flutter_iap 1.1.0

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

flutter_iap

Add In-App Payments to your Flutter app with this plugin.

  • You can fecth IAP products from Google Play and App Store
  • You can buy an IAP product
  • You can restore purchases from App Store (only iOS)

Getting Started

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

For help on editing plugin code, view the documentation.

Install

Add flutter_iap as a dependency in pubspec.yaml

For help on adding as a dependency, view the documentation.

Example

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

void main() {
  runApp(new MyApp());
}

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

class _MyAppState extends State<MyApp> {

  List<String> _productIds = [];

  @override initState() {
    super.initState();
    init();
  }

  init() async {
    IAPResponse response = await FlutterIap.fetchProducts(["com.example.testiap"]);
    List<IAPProduct> productIds = response.products;
    if (!mounted)
      return;

    setState(() {
      _productIds = productIds;
    });
  }

  @override Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('IAP example app'),
        ),
        body: new Center(
          child: new Text('Fetched: ${_productIds.map<String>((product) => "${product.productIdentifier}-${product.localizedPrice}").toList()}\n'),
        ),
        floatingActionButton: new FloatingActionButton(
          child: new Icon(Icons.monetization_on),
          onPressed: () {
            FlutterIap.buy(_productIds.first.productIdentifier);
          },
        ),
      ),
    );
  }
}

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() {
  runApp(new MyApp());
}

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

class _MyAppState extends State<MyApp> {

  List<IAPProduct> _productIds = [];

  @override initState() {
    super.initState();
    init();
  }

  init() async {
    IAPResponse response = await FlutterIap.fetchProducts(["com.example.testiap"]);
    List<IAPProduct> productIds = response.products;

    if (!mounted)
      return;

    setState(() {
      _productIds = productIds;
    });
  }

  @override Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('IAP example app'),
        ),
        body: new Center(
          child: new Text('Fetched: ${_productIds.map<String>((product) => "${product.productIdentifier}-${product.localizedPrice}").toList()}\n'),
        ),
        floatingActionButton: new FloatingActionButton(
          child: new Icon(Icons.monetization_on),
          onPressed: () {
            FlutterIap.buy(_productIds.first.productIdentifier);
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_iap: "^1.1.0"

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_iap/flutter_iap.dart';
  
Version Uploaded Documentation Archive
1.1.0 May 30, 2018 Go to the documentation of flutter_iap 1.1.0 Download flutter_iap 1.1.0 archive
1.0.1 Dec 21, 2017 Go to the documentation of flutter_iap 1.0.1 Download flutter_iap 1.0.1 archive
1.0.0 Oct 22, 2017 Go to the documentation of flutter_iap 1.0.0 Download flutter_iap 1.0.0 archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
71 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
85
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • The description is too short.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <2.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7