flutter_billing 0.1.0 flutter_billing: ^0.1.0 copied to clipboard
A flutter plugin to communicate with billing on iOS and Android.
flutter_billing #
A plugin for Flutter that enables communication with billing API in iOS and Android.
Warning: This plugin is still under development, some billing features are not available yet and testing has been limited. Feedback and Pull Requests are welcome.
Using #
Add flutter_billing: 0.1.0
as a dependency in pubspec.yaml
.
Create an instance of the plugin:
final Billing billing = new Billing(onError: (e) {
// optionally handle exception
});
Request available products for purchase:
final List<BillingProduct> products = await billing.getProducts(<String>[
'my.product.id',
'my.other.product.id',
]);
or
final BillingProduct product = await billing.getProduct('my.product.id');
if (product != null) {
// success
} else {
// something went wrong
}
Request purchased products (each purchase is a product identifier):
final Set<String> purchases = await billing.getPurchases();
Check if a product is already purchased:
final bool purchased = purchases.contains('my.product.id');
or
final bool purchases = await billing.isPurchased('my.product.id');
Purchase a product:
final bool purchased = await billing.purchase(productId);
Limitations #
This is just an initial version of the plugin. There are still some limitations:
- iOS implementation is currently under testing
- Only non-consumable in app products are supported