[in_app_purchase] Fix most failing pedantic lints (#2317)
None of these fixes should affect functionality. There are dozens of
undocumented public API members that still need to be documented to
completely remove the analysis_options for this package.
diff --git a/packages/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/CHANGELOG.md
index 2624cad..451953d 100644
--- a/packages/in_app_purchase/CHANGELOG.md
+++ b/packages/in_app_purchase/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.2.2+3
+
+* Fix failing pedantic lints. None of these fixes should have any change in
+ functionality.
+
## 0.2.2+2
* Include lifecycle dependency as a compileOnly one on Android to resolve
diff --git a/packages/in_app_purchase/analysis_options.yaml b/packages/in_app_purchase/analysis_options.yaml
index 6a095d6..8e4af76 100644
--- a/packages/in_app_purchase/analysis_options.yaml
+++ b/packages/in_app_purchase/analysis_options.yaml
@@ -7,10 +7,4 @@
analyzer:
errors:
- avoid_init_to_null: ignore
- prefer_is_empty: ignore
- prefer_is_not_empty: ignore
public_member_api_docs: ignore
- type_init_formals: ignore
- unnecessary_new: ignore
- unawaited_futures: ignore
diff --git a/packages/in_app_purchase/example/lib/main.dart b/packages/in_app_purchase/example/lib/main.dart
index 729fc0f..8d142c8 100644
--- a/packages/in_app_purchase/example/lib/main.dart
+++ b/packages/in_app_purchase/example/lib/main.dart
@@ -36,7 +36,7 @@
bool _isAvailable = false;
bool _purchasePending = false;
bool _loading = true;
- String _queryProductError = null;
+ String _queryProductError;
@override
void initState() {
@@ -149,12 +149,12 @@
stack.add(
Stack(
children: [
- new Opacity(
+ Opacity(
opacity: 0.3,
child: const ModalBarrier(dismissible: false, color: Colors.grey),
),
- new Center(
- child: new CircularProgressIndicator(),
+ Center(
+ child: CircularProgressIndicator(),
),
],
),
@@ -213,7 +213,7 @@
title: Text('Products for Sale',
style: Theme.of(context).textTheme.headline));
List<ListTile> productList = <ListTile>[];
- if (!_notFoundIds.isEmpty) {
+ if (_notFoundIds.isNotEmpty) {
productList.add(ListTile(
title: Text('[${_notFoundIds.join(", ")}] not found',
style: TextStyle(color: ThemeData.light().errorColor)),
@@ -375,10 +375,12 @@
}
}
if (Platform.isIOS) {
- InAppPurchaseConnection.instance.completePurchase(purchaseDetails);
+ await InAppPurchaseConnection.instance
+ .completePurchase(purchaseDetails);
} else if (Platform.isAndroid) {
if (!kAutoConsume && purchaseDetails.productID == _kConsumableId) {
- InAppPurchaseConnection.instance.consumePurchase(purchaseDetails);
+ await InAppPurchaseConnection.instance
+ .consumePurchase(purchaseDetails);
}
}
}
diff --git a/packages/in_app_purchase/example/test_driver/test/in_app_purchase_e2e_test.dart b/packages/in_app_purchase/example/test_driver/test/in_app_purchase_e2e_test.dart
index d0a7005..449af66 100644
--- a/packages/in_app_purchase/example/test_driver/test/in_app_purchase_e2e_test.dart
+++ b/packages/in_app_purchase/example/test_driver/test/in_app_purchase_e2e_test.dart
@@ -10,6 +10,6 @@
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
- driver.close();
+ await driver.close();
exit(result == 'pass' ? 0 : 1);
}
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 e2bea9f..30f8732 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
@@ -101,8 +101,7 @@
@BillingResponseConverter()
class PurchasesResultWrapper {
PurchasesResultWrapper(
- {@required BillingResponse this.responseCode,
- @required List<PurchaseWrapper> this.purchasesList});
+ {@required this.responseCode, @required this.purchasesList});
factory PurchasesResultWrapper.fromJson(Map<String, dynamic> map) =>
_$PurchasesResultWrapperFromJson(map);
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 e6b8ac5..956eb09 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
@@ -154,7 +154,7 @@
.toList();
}
List<String> invalidIdentifiers = response.invalidProductIdentifiers ?? [];
- if (productDetails.length == 0) {
+ if (productDetails.isEmpty) {
invalidIdentifiers = identifiers.toList();
}
ProductDetailsResponse productDetailsResponse = ProductDetailsResponse(
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 d64467e..96a3d0c 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
@@ -238,7 +238,7 @@
..status = status
..error = error);
}).toList();
- if (!purchases.isEmpty) {
+ if (purchases.isNotEmpty) {
return Future.wait(purchases);
} else {
return [
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 46088b9..73990e8 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
@@ -249,7 +249,7 @@
{@required this.source,
@required this.code,
@required this.message,
- this.details = null});
+ this.details});
/// Which source is the error on.
final IAPSource source;
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 2cfbb0c..9808bba 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
@@ -17,8 +17,8 @@
@required this.title,
@required this.description,
@required this.price,
- this.skProduct = null,
- this.skuDetail = null});
+ this.skProduct,
+ this.skuDetail});
/// The identifier of the product, specified in App Store Connect or Sku in Google Play console.
final String id;
@@ -67,9 +67,7 @@
/// A list of [ProductDetails] can be obtained from the this response.
class ProductDetailsResponse {
ProductDetailsResponse(
- {@required this.productDetails,
- @required this.notFoundIDs,
- this.error = null});
+ {@required this.productDetails, @required this.notFoundIDs, this.error});
/// Each [ProductDetails] uniquely matches one valid identifier in [identifiers] of [InAppPurchaseConnection.queryProductDetails].
final List<ProductDetails> productDetails;
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 b980b01..d5e8612 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
@@ -142,8 +142,8 @@
@required this.productID,
@required this.verificationData,
@required this.transactionDate,
- this.skPaymentTransaction = null,
- this.billingClientPurchase = null,
+ this.skPaymentTransaction,
+ this.billingClientPurchase,
});
/// Generate a [PurchaseDetails] object based on an iOS [SKTransactionWrapper] object.
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 a5084b5..eb3ed4a 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
@@ -35,7 +35,7 @@
return _singleton;
}
- static final SKPaymentQueueWrapper _singleton = new SKPaymentQueueWrapper._();
+ static final SKPaymentQueueWrapper _singleton = SKPaymentQueueWrapper._();
SKPaymentQueueWrapper._() {
callbackChannel.setMethodCallHandler(_handleObserverCallbacks);
diff --git a/packages/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/pubspec.yaml
index 73f0e4f..0e618cd 100644
--- a/packages/in_app_purchase/pubspec.yaml
+++ b/packages/in_app_purchase/pubspec.yaml
@@ -2,7 +2,7 @@
description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase
-version: 0.2.2+2
+version: 0.2.2+3
dependencies: