From 14723738ebafac61d48cb18ef8aaf0b911dacbad Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Wed, 28 Oct 2020 11:11:30 -0700 Subject: [PATCH 1/2] [in_app_purchase] Remove the custom analysis options and fix the failing lints. The custom analysis_options was excluding the lint for documenting all public methods. So this PR mostly adds Dartdocs, however there are a few non Dartdoc changes: * example/lib/main.dart: make MyApp and kAutoConsume private. * lib/src/in_app_purchase/app_store_connection.dart: adds a @visibleForTesting AppStoreConnection constructor. * lib/src/in_app_purchase/app_store_connection.dart: adds a @visibleForTesting AppStoreConnection.observer getter. --- packages/in_app_purchase/analysis_options.yaml | 10 ---------- .../example/lib/consumable_store.dart | 13 +++++++++++-- packages/in_app_purchase/example/lib/main.dart | 12 ++++++------ .../billing_client_wrapper.dart | 16 ++++++++++++++++ .../billing_client_wrappers/enum_converters.dart | 6 ++++++ .../purchase_wrapper.dart | 8 ++++++++ .../sku_details_wrapper.dart | 5 +++++ packages/in_app_purchase/lib/src/channel.dart | 5 +++++ .../in_app_purchase/app_store_connection.dart | 11 +++++++++++ .../in_app_purchase/google_play_connection.dart | 8 ++++++++ .../in_app_purchase_connection.dart | 8 +++++++- .../lib/src/in_app_purchase/product_details.dart | 2 ++ .../src/in_app_purchase/purchase_details.dart | 13 +++++++++++++ .../src/store_kit_wrappers/enum_converters.dart | 2 ++ .../sk_payment_queue_wrapper.dart | 2 ++ .../sk_payment_transaction_wrappers.dart | 1 + .../store_kit_wrappers/sk_product_wrapper.dart | 10 ++++++++++ script/incremental_build.sh | 1 - 18 files changed, 113 insertions(+), 20 deletions(-) delete mode 100644 packages/in_app_purchase/analysis_options.yaml diff --git a/packages/in_app_purchase/analysis_options.yaml b/packages/in_app_purchase/analysis_options.yaml deleted file mode 100644 index 8e4af76f0a30..000000000000 --- a/packages/in_app_purchase/analysis_options.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# This is a temporary file to allow us to land a new set of linter rules in a -# series of manageable patches instead of one gigantic PR. It disables some of -# the new lints that are already failing on this plugin, for this plugin. It -# should be deleted and the failing lints addressed as soon as possible. - -include: ../../analysis_options.yaml - -analyzer: - errors: - public_member_api_docs: ignore diff --git a/packages/in_app_purchase/example/lib/consumable_store.dart b/packages/in_app_purchase/example/lib/consumable_store.dart index 12121a9d30ce..3c2bec95646d 100644 --- a/packages/in_app_purchase/example/lib/consumable_store.dart +++ b/packages/in_app_purchase/example/lib/consumable_store.dart @@ -5,22 +5,31 @@ import 'dart:async'; import 'package:shared_preferences/shared_preferences.dart'; -// This is just a development prototype for locally storing consumables. Do not -// use this. +/// A store of consumable items. +/// +/// This is a development prototype tha stores consumables in the shared +/// preferences. Do not use this in real world apps. class ConsumableStore { static const String _kPrefKey = 'consumables'; static Future _writes = Future.value(); + /// Adds a consumable with ID `id` to the store. + /// + /// The consumable is only added after the returned Future is complete. static Future save(String id) { _writes = _writes.then((void _) => _doSave(id)); return _writes; } + /// Consumes a consumable with ID `id` from the store. + /// + /// The consumable was only consumed after the returned Future is complete. static Future consume(String id) { _writes = _writes.then((void _) => _doConsume(id)); return _writes; } + /// Returns the list of consumables from the store. static Future> load() async { return (await SharedPreferences.getInstance()).getStringList(_kPrefKey) ?? []; diff --git a/packages/in_app_purchase/example/lib/main.dart b/packages/in_app_purchase/example/lib/main.dart index 352ad3b3402a..b285b6e2bb87 100644 --- a/packages/in_app_purchase/example/lib/main.dart +++ b/packages/in_app_purchase/example/lib/main.dart @@ -13,10 +13,10 @@ void main() { // [enablePendingPurchases](https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder.html#enablependingpurchases) // as part of initializing the app. InAppPurchaseConnection.enablePendingPurchases(); - runApp(MyApp()); + runApp(_MyApp()); } -const bool kAutoConsume = true; +const bool _kAutoConsume = true; const String _kConsumableId = 'consumable'; const List _kProductIds = [ @@ -25,12 +25,12 @@ const List _kProductIds = [ 'subscription' ]; -class MyApp extends StatefulWidget { +class _MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } -class _MyAppState extends State { +class _MyAppState extends State<_MyApp> { final InAppPurchaseConnection _connection = InAppPurchaseConnection.instance; StreamSubscription> _subscription; List _notFoundIds = []; @@ -257,7 +257,7 @@ class _MyAppState extends State { if (productDetails.id == _kConsumableId) { _connection.buyConsumable( purchaseParam: purchaseParam, - autoConsume: kAutoConsume || Platform.isIOS); + autoConsume: _kAutoConsume || Platform.isIOS); } else { _connection.buyNonConsumable( purchaseParam: purchaseParam); @@ -374,7 +374,7 @@ class _MyAppState extends State { } } if (Platform.isAndroid) { - if (!kAutoConsume && purchaseDetails.productID == _kConsumableId) { + if (!_kAutoConsume && purchaseDetails.productID == _kConsumableId) { await InAppPurchaseConnection.instance .consumePurchase(purchaseDetails); } diff --git a/packages/in_app_purchase/lib/src/billing_client_wrappers/billing_client_wrapper.dart b/packages/in_app_purchase/lib/src/billing_client_wrappers/billing_client_wrapper.dart index ebbd90aba0f4..0c8b348f4cd0 100644 --- a/packages/in_app_purchase/lib/src/billing_client_wrappers/billing_client_wrapper.dart +++ b/packages/in_app_purchase/lib/src/billing_client_wrappers/billing_client_wrapper.dart @@ -12,6 +12,7 @@ import 'purchase_wrapper.dart'; import 'sku_details_wrapper.dart'; import 'enum_converters.dart'; +/// Method identifier for the OnPurchaseUpdated method channel method. @visibleForTesting const String kOnPurchasesUpdated = 'PurchasesUpdatedListener#onPurchasesUpdated(int, List)'; @@ -51,6 +52,9 @@ typedef void PurchasesUpdatedListener(PurchasesResultWrapper purchasesResult); class BillingClient { bool _enablePendingPurchases = false; + /// Creates a billing client. + /// + /// The `onPurchasesUpdated` parameter must not be null. BillingClient(PurchasesUpdatedListener onPurchasesUpdated) { assert(onPurchasesUpdated != null); channel.setMethodCallHandler(callHandler); @@ -273,6 +277,7 @@ class BillingClient { })); } + /// The method call handler for [channel]. @visibleForTesting Future callHandler(MethodCall call) async { switch (call.method) { @@ -309,36 +314,47 @@ enum BillingResponse { // WARNING: Changes to this class need to be reflected in our generated code. // Run `flutter packages pub run build_runner watch` to rebuild and watch for // further changes. + /// The requested feature is not supported by Play Store on the current device. @JsonValue(-2) featureNotSupported, + /// The play Store service is not connected now - potentially transient state. @JsonValue(-1) serviceDisconnected, + /// Success. @JsonValue(0) ok, + /// The user pressed back or canceled a dialog. @JsonValue(1) userCanceled, + /// The network connection is down. @JsonValue(2) serviceUnavailable, + /// The billing API version is not supported for the type requested. @JsonValue(3) billingUnavailable, + /// The requested product is not available for purchase. @JsonValue(4) itemUnavailable, + /// Invalid arguments provided to the API. @JsonValue(5) developerError, + /// Fatal error during the API action. @JsonValue(6) error, + /// Failure to purchase since item is already owned. @JsonValue(7) itemAlreadyOwned, + /// Failure to consume since item is not owned. @JsonValue(8) itemNotOwned, } diff --git a/packages/in_app_purchase/lib/src/billing_client_wrappers/enum_converters.dart b/packages/in_app_purchase/lib/src/billing_client_wrappers/enum_converters.dart index 1e81895438c3..966c89176b1e 100644 --- a/packages/in_app_purchase/lib/src/billing_client_wrappers/enum_converters.dart +++ b/packages/in_app_purchase/lib/src/billing_client_wrappers/enum_converters.dart @@ -13,6 +13,7 @@ part 'enum_converters.g.dart'; /// Use these in `@JsonSerializable()` classes by annotating them with /// `@BillingResponseConverter()`. class BillingResponseConverter implements JsonConverter { + /// Default const constructor. const BillingResponseConverter(); @override @@ -28,6 +29,7 @@ class BillingResponseConverter implements JsonConverter { /// Use these in `@JsonSerializable()` classes by annotating them with /// `@SkuTypeConverter()`. class SkuTypeConverter implements JsonConverter { + /// Default const constructor. const SkuTypeConverter(); @override @@ -52,6 +54,7 @@ class _SerializedEnums { /// `@PurchaseStateConverter()`. class PurchaseStateConverter implements JsonConverter { + /// Default const constructor. const PurchaseStateConverter(); @override @@ -63,6 +66,9 @@ class PurchaseStateConverter int toJson(PurchaseStateWrapper object) => _$PurchaseStateWrapperEnumMap[object]; + /// Converts the purchase state stored in `object` to a [PurchaseStatus]. + /// + /// [PurchaseStateWrapper.unspecified_state] is mapped to [PurchaseStatus.error]. PurchaseStatus toPurchaseStatus(PurchaseStateWrapper object) { switch (object) { case PurchaseStateWrapper.pending: diff --git a/packages/in_app_purchase/lib/src/billing_client_wrappers/purchase_wrapper.dart b/packages/in_app_purchase/lib/src/billing_client_wrappers/purchase_wrapper.dart index 0d4b74f41ab5..8bdd738e7ed3 100644 --- a/packages/in_app_purchase/lib/src/billing_client_wrappers/purchase_wrapper.dart +++ b/packages/in_app_purchase/lib/src/billing_client_wrappers/purchase_wrapper.dart @@ -24,6 +24,7 @@ part 'purchase_wrapper.g.dart'; @JsonSerializable() @PurchaseStateConverter() class PurchaseWrapper { + /// Creates a purchase wrapper with the given purchase details. @visibleForTesting PurchaseWrapper( {@required this.orderId, @@ -38,6 +39,7 @@ class PurchaseWrapper { @required this.isAcknowledged, @required this.purchaseState}); + /// Factory for creating a [PurchaseWrapper] from a [Map] with the purchase details. factory PurchaseWrapper.fromJson(Map map) => _$PurchaseWrapperFromJson(map); @override @@ -132,6 +134,7 @@ class PurchaseWrapper { // For now, we keep them separated classes to be consistent with Android's BillingClient implementation. @JsonSerializable() class PurchaseHistoryRecordWrapper { + /// Creates a [PurchaseHistoryRecordWrapper] with the given record details. @visibleForTesting PurchaseHistoryRecordWrapper({ @required this.purchaseTime, @@ -142,6 +145,7 @@ class PurchaseHistoryRecordWrapper { @required this.developerPayload, }); + /// Factory for creating a [PurchaseHistoryRecordWrapper] from a [Map] with the record details. factory PurchaseHistoryRecordWrapper.fromJson(Map map) => _$PurchaseHistoryRecordWrapperFromJson(map); @@ -197,11 +201,13 @@ class PurchaseHistoryRecordWrapper { @JsonSerializable() @BillingResponseConverter() class PurchasesResultWrapper { + /// Creates a [PurchasesResultWrapper] with the given purchase result details. PurchasesResultWrapper( {@required this.responseCode, @required this.billingResult, @required this.purchasesList}); + /// Factory for creating a [PurchaseResultWrapper] from a [Map] with the result details. factory PurchasesResultWrapper.fromJson(Map map) => _$PurchasesResultWrapperFromJson(map); @@ -240,9 +246,11 @@ class PurchasesResultWrapper { @JsonSerializable() @BillingResponseConverter() class PurchasesHistoryResult { + /// Creates a [PurchasesHistoryResult] with the provided history. PurchasesHistoryResult( {@required this.billingResult, @required this.purchaseHistoryRecordList}); + /// Factory for creating a [PurchasesHistoryResult] from a [Map] with the history result details. factory PurchasesHistoryResult.fromJson(Map map) => _$PurchasesHistoryResultFromJson(map); diff --git a/packages/in_app_purchase/lib/src/billing_client_wrappers/sku_details_wrapper.dart b/packages/in_app_purchase/lib/src/billing_client_wrappers/sku_details_wrapper.dart index 4d6a9307a53a..db65e2064a14 100644 --- a/packages/in_app_purchase/lib/src/billing_client_wrappers/sku_details_wrapper.dart +++ b/packages/in_app_purchase/lib/src/billing_client_wrappers/sku_details_wrapper.dart @@ -19,6 +19,7 @@ part 'sku_details_wrapper.g.dart'; @JsonSerializable() @SkuTypeConverter() class SkuDetailsWrapper { + /// Creates a [SkuDetailsWrapper] with the given purchase details. @visibleForTesting SkuDetailsWrapper({ @required this.description, @@ -47,6 +48,7 @@ class SkuDetailsWrapper { factory SkuDetailsWrapper.fromJson(Map map) => _$SkuDetailsWrapperFromJson(map); + /// Textual description of the product. final String description; /// Trial period in ISO 8601 format. @@ -78,6 +80,8 @@ class SkuDetailsWrapper { /// Applies to [SkuType.subs], formatted in ISO 8601. final String subscriptionPeriod; + + /// The product's title. final String title; /// The [SkuType] of the product. @@ -143,6 +147,7 @@ class SkuDetailsWrapper { /// Returned by [BillingClient.querySkuDetails]. @JsonSerializable() class SkuDetailsResponseWrapper { + /// Creates a [SkuDetailsResponseWrapper] with the given purchase details. @visibleForTesting SkuDetailsResponseWrapper( {@required this.billingResult, this.skuDetailsList}); diff --git a/packages/in_app_purchase/lib/src/channel.dart b/packages/in_app_purchase/lib/src/channel.dart index b10507067ca5..a0b92b5d5f1e 100644 --- a/packages/in_app_purchase/lib/src/channel.dart +++ b/packages/in_app_purchase/lib/src/channel.dart @@ -4,8 +4,13 @@ import 'package:flutter/services.dart'; +/// Method channel for the plugin's platform<-->Dart calls (all but the +/// ios->Dart calls which are carried over the [callbackChannel]). const MethodChannel channel = MethodChannel('plugins.flutter.io/in_app_purchase'); +/// Method channel for the plugin's ios->Dart calls. +// This is in a separate channel due to historic reasons only. +// TODO(cyanglaz): Remove this. https://github.com/flutter/flutter/issues/69225 const MethodChannel callbackChannel = MethodChannel('plugins.flutter.io/in_app_purchase_callback'); diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/app_store_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/app_store_connection.dart index da6fc7417585..a244ab13fc28 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/app_store_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/app_store_connection.dart @@ -18,14 +18,25 @@ import '../../billing_client_wrappers.dart'; /// This translates various `StoreKit` calls and responses into the /// generic plugin API. class AppStoreConnection implements InAppPurchaseConnection { + /// Returns the singleton instance of the [AppStoreConnection] that should be + /// used across the app. static AppStoreConnection get instance => _getOrCreateInstance(); static AppStoreConnection _instance; static SKPaymentQueueWrapper _skPaymentQueueWrapper; static _TransactionObserver _observer; + /// Creates an [AppStoreConnection] object. + /// + /// This constructor should only be used for testing, for any other purpose + /// get the connection from the [instance] getter. + @visibleForTesting + AppStoreConnection(); + Stream> get purchaseUpdatedStream => _observer.purchaseUpdatedController.stream; + /// Callback handler for transaction status changes. + @visibleForTesting static SKTransactionObserverWrapper get observer => _observer; static AppStoreConnection _getOrCreateInstance() { diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart index 581a7bd9f8fe..4c979abb8e49 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart @@ -32,6 +32,7 @@ class GooglePlayConnection _purchaseUpdatedController = StreamController.broadcast(); ; } + /// Returns the singleton instance of the [GooglePlayConnection]. static GooglePlayConnection get instance => _getOrCreateInstance(); static GooglePlayConnection _instance; @@ -39,6 +40,9 @@ class GooglePlayConnection _purchaseUpdatedController.stream; static StreamController> _purchaseUpdatedController; + /// The [BillingClient] that's abstracted by [GooglePlayConnection]. + /// + /// This field should not be used out of test code. @visibleForTesting final BillingClient billingClient; @@ -161,6 +165,10 @@ class GooglePlayConnection 'The method only works on iOS.'); } + /// Resets the connection instance. + /// + /// The next call to [instance] will create a new instance. Should only be + /// used in tests. @visibleForTesting static void reset() => _instance = null; diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart index ba3932f73878..be13883bf13e 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart @@ -269,7 +269,12 @@ abstract class InAppPurchaseConnection { } /// Which platform the request is on. -enum IAPSource { GooglePlay, AppStore } +enum IAPSource { + /// Google's Play Store. + GooglePlay, + /// Apple's App Store. + AppStore +} /// Captures an error from the underlying purchase platform. /// @@ -279,6 +284,7 @@ enum IAPSource { GooglePlay, AppStore } /// * [ProductDetailsResponse] for error when querying product details. /// * [PurchaseDetails] for error happened in purchase. class IAPError { + /// Creates a new IAP error object with the given error details. IAPError( {@required this.source, @required this.code, diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/product_details.dart b/packages/in_app_purchase/lib/src/in_app_purchase/product_details.dart index 9808bba999fe..bb9e2682b9b7 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/product_details.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/product_details.dart @@ -12,6 +12,7 @@ import 'in_app_purchase_connection.dart'; /// This class unifies the BillingClient's [SkuDetailsWrapper] and StoreKit's [SKProductWrapper]. You can use the common attributes in /// This class for simple operations. If you would like to see the detailed representation of the product, instead, use [skuDetails] on Android and [skProduct] on iOS. class ProductDetails { + /// Creates a new product details object with the provided details. ProductDetails( {@required this.id, @required this.title, @@ -66,6 +67,7 @@ class ProductDetails { /// /// A list of [ProductDetails] can be obtained from the this response. class ProductDetailsResponse { + /// Creates a new [ProductDetailsResponse] with the provided response details. ProductDetailsResponse( {@required this.productDetails, @required this.notFoundIDs, this.error}); diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/purchase_details.dart b/packages/in_app_purchase/lib/src/in_app_purchase/purchase_details.dart index 2321bd00abdc..708b42c01623 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/purchase_details.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/purchase_details.dart @@ -10,9 +10,15 @@ import 'package:in_app_purchase/src/store_kit_wrappers/sk_payment_transaction_wr import './in_app_purchase_connection.dart'; import './product_details.dart'; +/// [IAPError.code] code for failed purchases. final String kPurchaseErrorCode = 'purchase_error'; + +/// [IAPError.code] code used when a query for previouys transaction has failed. final String kRestoredPurchaseErrorCode = 'restore_transactions_failed'; + +/// [IAPError.code] code used when a consuming a purchased item fails. final String kConsumptionFailedErrorCode = 'consume_purchase_failed'; + final String _kPlatformIOS = 'ios'; final String _kPlatformAndroid = 'android'; @@ -51,12 +57,16 @@ class PurchaseVerificationData { /// Indicates the source of the purchase. final IAPSource source; + /// Creates a [PurchaseVerificationData] object with the provided information. PurchaseVerificationData( {@required this.localVerificationData, @required this.serverVerificationData, @required this.source}); } +/// Status for a [PurchaseDetails]. +/// +/// This is the type for [PurchaseDetails.status]. enum PurchaseStatus { /// The purchase process is pending. /// @@ -76,6 +86,7 @@ enum PurchaseStatus { /// The parameter object for generating a purchase. class PurchaseParam { + /// Creates a new purchase parameter object with the given data. PurchaseParam( {@required this.productDetails, this.applicationUserName, @@ -170,6 +181,7 @@ class PurchaseDetails { // The value is either '_kPlatformIOS' or '_kPlatformAndroid'. String _platform; + /// Creates a new PurchaseDetails object with the provided data. PurchaseDetails({ @required this.purchaseID, @required this.productID, @@ -233,6 +245,7 @@ class PurchaseDetails { /// /// An instance of this class is returned in [InAppPurchaseConnection.queryPastPurchases]. class QueryPurchaseDetailsResponse { + /// Creates a new [QueryPurchaseDetailsResponse] object with the provider information. QueryPurchaseDetailsResponse({@required this.pastPurchases, this.error}); /// A list of successfully fetched past purchases. diff --git a/packages/in_app_purchase/lib/src/store_kit_wrappers/enum_converters.dart b/packages/in_app_purchase/lib/src/store_kit_wrappers/enum_converters.dart index 49cfb78a686b..62188705035a 100644 --- a/packages/in_app_purchase/lib/src/store_kit_wrappers/enum_converters.dart +++ b/packages/in_app_purchase/lib/src/store_kit_wrappers/enum_converters.dart @@ -14,6 +14,7 @@ part 'enum_converters.g.dart'; /// `@SKTransactionStatusConverter()`. class SKTransactionStatusConverter implements JsonConverter { + /// Default const constructor. const SKTransactionStatusConverter(); @override @@ -23,6 +24,7 @@ class SKTransactionStatusConverter .cast(), json); + /// Converts an [SKPaymentTransactionStateWrapper] to a [PurchaseStatus]. PurchaseStatus toPurchaseStatus(SKPaymentTransactionStateWrapper object) { switch (object) { case SKPaymentTransactionStateWrapper.purchasing: diff --git a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart index bb731ac3f2aa..ce38759c74ec 100644 --- a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart +++ b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart @@ -203,6 +203,7 @@ class SKPaymentQueueWrapper { /// [NSError](https://developer.apple.com/documentation/foundation/nserror?language=objc). @JsonSerializable(nullable: true) class SKError { + /// Creates a new [SKError] object with the provided information. SKError( {@required this.code, @required this.domain, @required this.userInfo}); @@ -258,6 +259,7 @@ class SKError { /// initiate a payment. @JsonSerializable(nullable: true) class SKPaymentWrapper { + /// Creates a new [SKPaymentWrapper] with the provided information. SKPaymentWrapper( {@required this.productIdentifier, this.applicationUsername, diff --git a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_transaction_wrappers.dart b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_transaction_wrappers.dart index cb7ca03f38bc..65f6ff8871f8 100644 --- a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_transaction_wrappers.dart +++ b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_payment_transaction_wrappers.dart @@ -98,6 +98,7 @@ enum SKPaymentTransactionStateWrapper { /// [SKPaymentTransaction](https://developer.apple.com/documentation/storekit/skpaymenttransaction?language=objc). @JsonSerializable(nullable: true) class SKPaymentTransactionWrapper { + /// Creates a new [SKPaymentTransactionWrapper] with the provided information. SKPaymentTransactionWrapper({ @required this.payment, @required this.transactionState, diff --git a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart index 8f4c815a8f50..64e529b0c738 100644 --- a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -18,6 +18,7 @@ part 'sk_product_wrapper.g.dart'; /// Contains information about a list of products and a list of invalid product identifiers. @JsonSerializable() class SkProductResponseWrapper { + /// Creates an [SkProductResponseWrapper] with the given product details. SkProductResponseWrapper( {@required this.products, @required this.invalidProductIdentifiers}); @@ -67,12 +68,17 @@ class SkProductResponseWrapper { // The values of the enum options are matching the [SKProductPeriodUnit]'s values. Should there be an update or addition // in the [SKProductPeriodUnit], this need to be updated to match. enum SKSubscriptionPeriodUnit { + /// An interval lasting one day. @JsonValue(0) day, + /// An interval lasting one month. @JsonValue(1) + /// An interval lasting one week. week, @JsonValue(2) + /// An interval lasting one month. month, + /// An interval lasting one year. @JsonValue(3) year, } @@ -83,6 +89,7 @@ enum SKSubscriptionPeriodUnit { /// It is used as a property in [SKProductDiscountWrapper] and [SKProductWrapper]. @JsonSerializable(nullable: true) class SKProductSubscriptionPeriodWrapper { + /// Creates an [SKProductSubscriptionPeriodWrapper] for a `numberOfUnits`x`unit` period. SKProductSubscriptionPeriodWrapper( {@required this.numberOfUnits, @required this.unit}); @@ -143,6 +150,7 @@ enum SKProductDiscountPaymentMode { /// It is used as a property in [SKProductWrapper]. @JsonSerializable(nullable: true) class SKProductDiscountWrapper { + /// Creates an [SKProductDiscountWrapper] with the given discount details. SKProductDiscountWrapper( {@required this.price, @required this.priceLocale, @@ -206,6 +214,7 @@ class SKProductDiscountWrapper { /// should be stored for use when making a payment. @JsonSerializable(nullable: true) class SKProductWrapper { + /// Creates an [SKProductWrapper] with the given product details. SKProductWrapper({ @required this.productIdentifier, @required this.localizedTitle, @@ -304,6 +313,7 @@ class SKProductWrapper { // https://github.com/flutter/flutter/issues/26610 @JsonSerializable() class SKPriceLocaleWrapper { + /// Creates a new price locale for `currencySymbol` and `currencyCode`. SKPriceLocaleWrapper( {@required this.currencySymbol, @required this.currencyCode}); diff --git a/script/incremental_build.sh b/script/incremental_build.sh index 8e9cf34b1cda..896cceebf2b5 100755 --- a/script/incremental_build.sh +++ b/script/incremental_build.sh @@ -20,7 +20,6 @@ fi # # TODO(mklim): Remove everything from this list. https://github.com/flutter/flutter/issues/45440 CUSTOM_ANALYSIS_PLUGINS=( - "in_app_purchase" "camera" "video_player/video_player_web" "google_maps_flutter/google_maps_flutter_web" From 8400c670dcd9b67c70f404a7f6dc49e76b4779c4 Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Wed, 28 Oct 2020 12:48:02 -0700 Subject: [PATCH 2/2] format --- .../lib/src/in_app_purchase/google_play_connection.dart | 1 + .../lib/src/in_app_purchase/in_app_purchase_connection.dart | 1 + .../lib/src/store_kit_wrappers/sk_product_wrapper.dart | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart index 4c979abb8e49..b980bbd77d85 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/google_play_connection.dart @@ -32,6 +32,7 @@ class GooglePlayConnection _purchaseUpdatedController = StreamController.broadcast(); ; } + /// Returns the singleton instance of the [GooglePlayConnection]. static GooglePlayConnection get instance => _getOrCreateInstance(); static GooglePlayConnection _instance; diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart index be13883bf13e..f07ff96d4403 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart @@ -272,6 +272,7 @@ abstract class InAppPurchaseConnection { enum IAPSource { /// Google's Play Store. GooglePlay, + /// Apple's App Store. AppStore } diff --git a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart index 64e529b0c738..aa76971102cf 100644 --- a/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -71,13 +71,17 @@ enum SKSubscriptionPeriodUnit { /// An interval lasting one day. @JsonValue(0) day, + /// An interval lasting one month. @JsonValue(1) + /// An interval lasting one week. week, @JsonValue(2) + /// An interval lasting one month. month, + /// An interval lasting one year. @JsonValue(3) year,