Skip to main content
Version: 6.3

API Reference

Complete reference for flutter_inapp_purchase v6.0.0 - A unified API for implementing in-app purchases across iOS and Android platforms.

Available APIs

🏪 Core Methods

Essential methods for initializing connections, loading products, and processing purchases.

  • Connection Management: initConnection(), endConnection()
  • Product Loading: getProducts(), getSubscriptions()
  • Purchase Processing: requestPurchase() (use type: PurchaseType.inapp or type: PurchaseType.subs)
  • Transaction Management: finishTransaction(), consumePurchase()

📱 Platform-Specific Methods

Access iOS and Android specific features and capabilities.

  • iOS Features: Offer code redemption, subscription management, StoreKit 2 support
  • Android Features: Billing client state, pending purchases, deep links

🎧 Event Listeners (Open IAP Spec)

Real-time streams for monitoring purchase events and connection states.

  • purchaseUpdatedListener: Stream for successful purchase updates
  • purchaseErrorListener: Stream for purchase errors
  • Connection Events: Store connection status updates

🔧 Types & Enums

Comprehensive type definitions for type-safe development.

  • Request Objects: Platform-specific purchase and product requests
  • Response Models: Products, purchases, and transaction data
  • Error Handling: Detailed error codes and messages

Quick Start

Instance Management

flutter_inapp_purchase provides flexible instance management:

// Option 1: Create your own instance (recommended for most cases)
final iap = FlutterInappPurchase();

// Option 2: Use singleton for global state management
final iap = FlutterInappPurchase.instance;

// Option 3: Use with IapProvider (recommended for Flutter apps)
final iapProvider = IapProvider.of(context);

Basic Implementation

import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';

class PurchaseManager {
final FlutterInappPurchase iap = FlutterInappPurchase();
StreamSubscription<Purchase>? _purchaseSubscription;
StreamSubscription<PurchaseError>? _errorSubscription;

Future<void> initializePurchases() async {
// Initialize connection
await iap.initConnection();

// Set up listeners (Open IAP spec)
_purchaseSubscription = iap.purchaseUpdatedListener.listen(
(purchase) {
handlePurchaseSuccess(purchase);
},
);

_errorSubscription = iap.purchaseErrorListener.listen(
(error) {
handlePurchaseError(error);
},
);
}

Future<void> makePurchase(String productId) async {
await iap.requestPurchase(
request: RequestPurchase(
ios: RequestPurchaseIOS(sku: productId, quantity: 1),
android: RequestPurchaseAndroid(skus: [productId]),
),
type: PurchaseType.inapp,
);
}
}

Dart Type Safety

flutter_inapp_purchase provides full type safety with comprehensive type definitions for all methods, parameters, and return values.

Platform Compatibility

  • iOS: 12.0+ with StoreKit 2 (iOS 15.0+) and StoreKit 1 fallback
  • Android: API level 21+ with Google Play Billing Client v8

Need Help?