From 4acaedd34152f8d91eb8870e7211ba8fa7ce8e90 Mon Sep 17 00:00:00 2001 From: Umut Date: Sat, 2 Aug 2025 14:48:18 +0330 Subject: [PATCH 1/2] Update Flutter SDK and dependencies in pubspec.yaml --- pubspec.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 3cb5752..ce56262 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,17 +4,18 @@ version: 2.2.0-1.0.0-alpha01 homepage: https://github.com/cafebazaar/flutter_poolakey environment: - sdk: '>=3.0.6 <4.0.0' - flutter: ">=3.3.0" + sdk: ^3.8.0 + flutter: ">=1.17.0" dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.0.2 + plugin_platform_interface: ^2.1.8 dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^5.0.0 flutter: plugin: From 3e5d6f15fa7a30f1c2f8c4435c3f96a4c236c615 Mon Sep 17 00:00:00 2001 From: Umut Date: Sat, 2 Aug 2025 14:48:27 +0330 Subject: [PATCH 2/2] Refactor code formatting for improved readability in FlutterPoolakey, PurchaseInfo, and SkuDetails classes --- lib/flutter_poolakey.dart | 58 ++++++++++++++++++++++++--------------- lib/purchase_info.dart | 22 ++++++++------- lib/sku_details.dart | 3 +- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/lib/flutter_poolakey.dart b/lib/flutter_poolakey.dart index c7b83c4..abebde5 100644 --- a/lib/flutter_poolakey.dart +++ b/lib/flutter_poolakey.dart @@ -13,8 +13,9 @@ export 'sku_details.dart'; /// It only works in the Android platform (Because [Cafebazaar](https://cafebazaar.ir/?l=en) only supports Android) /// It uses [Poolakey](https://github.com/cafebazaar/Poolakey) SDK under the hood. class FlutterPoolakey { - static const MethodChannel _channel = - const MethodChannel('ir.cafebazaar.flutter_poolakey'); + static const MethodChannel _channel = const MethodChannel( + 'ir.cafebazaar.flutter_poolakey', + ); static Future getVersion() async { return await _channel.invokeMethod('version', {}); @@ -34,17 +35,23 @@ class FlutterPoolakey { /// You should listen to [onDisconnected] callback and call [FlutterPoolakey.connect] to reconnect again. /// /// This function may return an error, you should handle the error and check the stacktrace to resolve it. - static Future connect(String? inAppBillingKey, - {VoidCallback? onSucceed, - VoidCallback? onFailed, - VoidCallback? onDisconnected}) async { + static Future connect( + String? inAppBillingKey, { + VoidCallback? onSucceed, + VoidCallback? onFailed, + VoidCallback? onDisconnected, + }) async { _registerConnectCallBack(onSucceed, onFailed, onDisconnected); - await _channel - .invokeMethod('connect', {'in_app_billing_key': inAppBillingKey}); + await _channel.invokeMethod('connect', { + 'in_app_billing_key': inAppBillingKey, + }); } - static void _registerConnectCallBack(VoidCallback? onConnectionSucceed, - VoidCallback? onConnectionFailed, VoidCallback? onDisconnected) { + static void _registerConnectCallBack( + VoidCallback? onConnectionSucceed, + VoidCallback? onConnectionFailed, + VoidCallback? onDisconnected, + ) { if (onConnectionSucceed == null && onConnectionFailed == null && onDisconnected == null) { @@ -92,7 +99,7 @@ class FlutterPoolakey { final map = await _channel.invokeMethod('purchase', { 'product_id': productId, 'payload': payload, - 'dynamicPriceToken': dynamicPriceToken + 'dynamicPriceToken': dynamicPriceToken, }); return PurchaseInfo.fromMap(map); } @@ -117,7 +124,7 @@ class FlutterPoolakey { final map = await _channel.invokeMethod('subscribe', { 'product_id': productId, 'payload': payload, - 'dynamicPriceToken': dynamicPriceToken + 'dynamicPriceToken': dynamicPriceToken, }); return PurchaseInfo.fromMap(map); } @@ -135,8 +142,9 @@ class FlutterPoolakey { /// /// It returns true if the process is successful static Future consume(String purchaseToken) async { - return await _channel - .invokeMethod('consume', {'purchase_token': purchaseToken}); + return await _channel.invokeMethod('consume', { + 'purchase_token': purchaseToken, + }); } /// Returns all purchases list @@ -176,8 +184,9 @@ class FlutterPoolakey { /// /// Retrieves list of [PurchaseInfo] which contains all subscribed products in user's inventory. static Future> getAllSubscribedProducts() async { - final List list = - await _channel.invokeMethod("get_all_subscribed_products"); + final List list = await _channel.invokeMethod( + "get_all_subscribed_products", + ); return list.map((map) => PurchaseInfo.fromMap(map)).toList(); } @@ -204,9 +213,11 @@ class FlutterPoolakey { /// You can use this function to get detail of inApp product sku's, /// [skuIds] Contain all sku id's that you want to get info about it. static Future> getInAppSkuDetails( - List skuIds) async { - final List list = await _channel - .invokeMethod("get_in_app_sku_details", {'sku_ids': skuIds}); + List skuIds, + ) async { + final List list = await _channel.invokeMethod("get_in_app_sku_details", { + 'sku_ids': skuIds, + }); return list.map((map) => SkuDetails.fromMap(map)).toList(); } @@ -215,9 +226,12 @@ class FlutterPoolakey { /// You can use this function to get detail of subscription product sku's, /// [skuIds] Contain all sku id's that you want to get info about it. static Future> getSubscriptionSkuDetails( - List skuIds) async { - final List list = await _channel - .invokeMethod("get_subscription_sku_details", {'sku_ids': skuIds}); + List skuIds, + ) async { + final List list = await _channel.invokeMethod( + "get_subscription_sku_details", + {'sku_ids': skuIds}, + ); return list.map((map) => SkuDetails.fromMap(map)).toList(); } } diff --git a/lib/purchase_info.dart b/lib/purchase_info.dart index b999843..061c2a6 100644 --- a/lib/purchase_info.dart +++ b/lib/purchase_info.dart @@ -10,15 +10,16 @@ class PurchaseInfo { final String dataSignature; PurchaseInfo( - this.orderId, - this.purchaseToken, - this.payload, - this.packageName, - this.purchaseState, - this.purchaseTime, - this.productId, - this.originalJson, - this.dataSignature); + this.orderId, + this.purchaseToken, + this.payload, + this.packageName, + this.purchaseState, + this.purchaseTime, + this.productId, + this.originalJson, + this.dataSignature, + ); factory PurchaseInfo.fromMap(Map typeName) { return PurchaseInfo( @@ -35,7 +36,8 @@ class PurchaseInfo { } @override - String toString() => 'orderId: $orderId,' + String toString() => + 'orderId: $orderId,' '\npurchaseToken: $purchaseToken,' '\npayload: $payload,' '\npackageName: $packageName,' diff --git a/lib/sku_details.dart b/lib/sku_details.dart index 45b4607..d815910 100644 --- a/lib/sku_details.dart +++ b/lib/sku_details.dart @@ -18,7 +18,8 @@ class SkuDetails { } @override - String toString() => 'sku: $sku,' + String toString() => + 'sku: $sku,' '\ntype: $type,' '\nprice: $price,' '\ntitle: $title,'