flutter_store_kit 1.0.3 flutter_store_kit: ^1.0.3 copied to clipboard
Simplify in-app purchases in Flutter apps with `FlutterStoreKit`. Manage initialization, purchases, and subscriptions with ease. Ideal for premium content and subscriptions.
FlutterStoreKit Library #
FlutterStoreKit is a Flutter library that provides functionality for managing in-app purchases and subscriptions. This documentation outlines how to use the FlutterStoreKit library in your Flutter app.
1. Initialize the Store #
Initialize the store with your product IDs:
void main() {
StoreKit.instance.initialize([
'subscription_id1',
'subscription_id2',
'subscription_id3',
]);
}
2. Add Listeners #
Add Pro Status Changed Listener Add a listener for pro status changes:
void _onProStatusChanged() {
// Update UI based on purchase status
}
StoreKit.instance.addProStatusChangedListener(_onProStatusChanged);
Remove Pro Status Changed Listener Remove a listener for pro status changes:
StoreKit.instance.removeProStatusChangedListener(_onProStatusChanged);
Add Error Listener Add a listener for errors:
void _onError(String error) {
// Handle error
print("Error: $error");
}
StoreKit.instance.addErrorListener(_onError);
Remove Error Listener Remove a listener for errors:
StoreKit.instance.removeErrorListener(_onError);
3. Purchases #
Restore Past Purchases Restore past purchases for the user:
await StoreKit.instance.restorePastPurchases(context);
Purchase a Subscription Purchase a subscription item:
await StoreKit.instance.purchaseSubscription(subscriptionItem);
Open Subscription Management Page Open the subscription management page for the user:
await StoreKit.instance.openSubscriptionManagementPage();
Check if Product is Purchased Check if a product has been purchased:
bool purchased = StoreKit.instance.isProductPurchased('product_id');
Get Purchased Product IDs Get a list of purchased product IDs:
List<String> purchasedIds = StoreKit.instance.getPurchasedProductIds();
4. Disposal #
Dispose of the store instance:
StoreKit.instance.dispose();