Skip to content

hyochan/flutter_inapp_purchase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

flutter_inapp_purchase

flutter_inapp_purchase logo

Pub Version Flutter CI Coverage Status License

A comprehensive Flutter plugin for implementing in-app purchases that conforms to the Open IAP specification

Open IAP

πŸ“š Documentation

πŸ“– Visit our comprehensive documentation site β†’

πŸ“¦ Installation

dependencies:
  flutter_inapp_purchase: ^6.6.1

πŸ”§ Quick Start

Basic Usage

import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';

// Create instance
final iap = FlutterInappPurchase();

// Initialize connection
await iap.initConnection();

// Get products
final products = await iap.requestProducts(
  skus: ['product_id'],
  type: PurchaseType.inapp,
);

// Request purchase
await iap.requestPurchase(
  request: RequestPurchase(
    ios: RequestPurchaseIOS(sku: 'product_id'),
    android: RequestPurchaseAndroid(skus: ['product_id']),
  ),
  type: PurchaseType.inapp,
);

iOS Notes

  • This plugin uses the OpenIAP Apple native module via CocoaPods (openiap 1.1.9).
  • After upgrading, run pod install in your iOS project (e.g., example/ios).
  • Minimum iOS deployment target is 15.0 for StoreKit 2 support.

πŸ› οΈ Development

  • Install dependencies: flutter pub get
  • Run lints: dart analyze
  • Run tests: flutter test
  • Enable Git hooks (recommended): git config core.hooksPath .githooks
    • The pre-commit hook auto-formats staged Dart files and fails if any file remains unformatted. It also runs tests.
    • Tests: runs changed tests first, then full suite (fail-fast).
    • Env toggles:
      • SKIP_PRECOMMIT_TESTS=1 to skip tests
      • PRECOMMIT_TEST_CONCURRENCY=<N> to control concurrency (default 4)
      • PRECOMMIT_FAIL_FAST=0 to disable --fail-fast
      • PRECOMMIT_RUN_ALL_TESTS=0 to only run changed tests
      • ENFORCE_ANALYZE=1 to fail commit on analyzer warnings

Singleton Usage

For global state management or when you need a shared instance:

// Use singleton instance
final iap = FlutterInappPurchase.instance;
await iap.initConnection();

// The instance is shared across your app
final sameIap = FlutterInappPurchase.instance; // Same instance

Sponsors

πŸ’Ό View Our Sponsors

πŸ“„ License

MIT License - see LICENSE file for details.