From 5b39d8236b3caf4abcae53dae2fe40e620536612 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 10 Jul 2019 14:59:19 -0700 Subject: [PATCH 1/2] add missing hash code overrides --- packages/in_app_purchase/CHANGELOG.md | 4 +++ .../sk_payment_queue_wrapper.dart | 12 +++++++++ .../sk_payment_transaction_wrappers.dart | 10 ++++++++ .../sk_product_wrapper.dart | 25 +++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/packages/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/CHANGELOG.md index 0fb8ee77157d..e9de56b2cef3 100644 --- a/packages/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0+6 + +* Add missing `hashCode` implementations. + ## 0.2.0+5 * iOS: Support unsupported UserInfo value types on NSError. 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 b04a1ad3ab9d..a5084b5c80cb 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 @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:ui' show hashValues; import 'dart:async'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; @@ -236,6 +237,9 @@ class SKError { DeepCollectionEquality.unordered() .equals(typedOther.userInfo, userInfo); } + + @override + int get hashCode => hashValues(this.code, this.domain, this.userInfo); } /// Dart wrapper around StoreKit's @@ -327,6 +331,14 @@ class SKPaymentWrapper { typedOther.requestData == requestData; } + @override + int get hashCode => hashValues( + this.productIdentifier, + this.applicationUsername, + this.quantity, + this.simulatesAskToBuyInSandbox, + this.requestData); + @override String toString() => _$SKPaymentWrapperToJson(this).toString(); } 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 4475ce57aa59..f90684f374f5 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 @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:ui' show hashValues; import 'package:flutter/foundation.dart'; import 'package:json_annotation/json_annotation.dart'; import 'sk_product_wrapper.dart'; @@ -173,6 +174,15 @@ class SKPaymentTransactionWrapper { typedOther.error == error; } + @override + int get hashCode => hashValues( + this.payment, + this.transactionState, + this.originalTransaction, + this.transactionTimeStamp, + this.transactionIdentifier, + this.error); + @override String toString() => _$SKPaymentTransactionWrapperToJson(this).toString(); } 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 bac90f828326..0f6e42a49167 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 @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:ui' show hashValues; import 'package:flutter/foundation.dart'; import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -55,6 +56,9 @@ class SkProductResponseWrapper { DeepCollectionEquality().equals( typedOther.invalidProductIdentifiers, invalidProductIdentifiers); } + + @override + int get hashCode => hashValues(this.products, this.invalidProductIdentifiers); } /// Dart wrapper around StoreKit's [SKProductPeriodUnit](https://developer.apple.com/documentation/storekit/skproductperiodunit?language=objc). @@ -110,6 +114,9 @@ class SKProductSubscriptionPeriodWrapper { final SKProductSubscriptionPeriodWrapper typedOther = other; return typedOther.numberOfUnits == numberOfUnits && typedOther.unit == unit; } + + @override + int get hashCode => hashValues(this.numberOfUnits, this.unit); } /// Dart wrapper around StoreKit's [SKProductDiscountPaymentMode](https://developer.apple.com/documentation/storekit/skproductdiscountpaymentmode?language=objc). @@ -187,6 +194,10 @@ class SKProductDiscountWrapper { typedOther.paymentMode == paymentMode && typedOther.subscriptionPeriod == subscriptionPeriod; } + + @override + int get hashCode => hashValues(this.price, this.priceLocale, + this.numberOfPeriods, this.paymentMode, this.subscriptionPeriod); } /// Dart wrapper around StoreKit's [SKProduct](https://developer.apple.com/documentation/storekit/skproduct?language=objc). @@ -272,6 +283,17 @@ class SKProductWrapper { typedOther.subscriptionPeriod == subscriptionPeriod && typedOther.introductoryPrice == introductoryPrice; } + + @override + int get hashCode => hashValues( + this.productIdentifier, + this.localizedTitle, + this.localizedDescription, + this.priceLocale, + this.subscriptionGroupIdentifier, + this.price, + this.subscriptionPeriod, + this.introductoryPrice); } /// Object that indicates the locale of the price @@ -307,4 +329,7 @@ class SKPriceLocaleWrapper { final SKPriceLocaleWrapper typedOther = other; return typedOther.currencySymbol == currencySymbol; } + + @override + int get hashCode => this.currencySymbol.hashCode; } From f6fe7d142a10694df6aa590029d836341d364143 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 10 Jul 2019 15:02:54 -0700 Subject: [PATCH 2/2] update pubspec --- packages/in_app_purchase/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/pubspec.yaml index b2388983d965..78af9b15bf1c 100644 --- a/packages/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase 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 homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase -version: 0.2.0+5 +version: 0.2.0+6 dependencies: async: ^2.0.8