From 050a8d610e659c67eb0c2f4be61794091660b6cc Mon Sep 17 00:00:00 2001 From: Toni Rico Date: Fri, 17 Nov 2023 18:04:40 +0100 Subject: [PATCH] Fix flutter analyze deprecation warnings (#872) Looks like `describeEnum` was deprecated in the latest Flutter version and substituted with `name`. This PR changes current usages of that to fix the linter. From what I've been able to figure out, this `name` property is available since Dart 2.15, which is our minimum version so we should be good --- lib/purchases_flutter.dart | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/purchases_flutter.dart b/lib/purchases_flutter.dart index 3eac718e..431ed3b2 100644 --- a/lib/purchases_flutter.dart +++ b/lib/purchases_flutter.dart @@ -259,9 +259,9 @@ class Purchases { String typeString; // ignore: deprecated_member_use_from_same_package if (type != PurchaseType.subs) { - typeString = describeEnum(type); + typeString = type.name; } else { - typeString = describeEnum(productCategory); + typeString = productCategory.name; } final List result = await _channel.invokeMethod('getProductInfo', { @@ -304,7 +304,7 @@ class Purchases { final prorationMode = upgradeInfo?.prorationMode; final customerInfo = await _invokeReturningCustomerInfo('purchaseProduct', { 'productIdentifier': productIdentifier, - 'type': describeEnum(type), + 'type': type.name, 'googleOldProductIdentifier': upgradeInfo?.oldSKU, 'googleProrationMode': prorationMode?.index, 'googleIsPersonalizedPrice': null, @@ -339,9 +339,7 @@ class Purchases { final prorationMode = googleProductChangeInfo?.prorationMode?.value; final customerInfo = await _invokeReturningCustomerInfo('purchaseProduct', { 'productIdentifier': storeProduct.identifier, - 'type': storeProduct.productCategory != null - ? describeEnum(storeProduct.productCategory!) - : null, + 'type': storeProduct.productCategory?.name, 'googleOldProductIdentifier': googleProductChangeInfo?.oldProductIdentifier, 'googleProrationMode': prorationMode, @@ -540,7 +538,7 @@ class Purchases { /// The default is {LOG_LEVEL.INFO} in release builds and {LOG_LEVEL.DEBUG} in debug builds. static Future setLogLevel(LogLevel level) => _channel.invokeMethod( 'setLogLevel', - {'level': describeEnum(level).toUpperCase()}, + {'level': level.name.toUpperCase()}, ); /// @@ -929,7 +927,7 @@ class Purchases { final args = Map.from(call.arguments); final logLevelName = args['logLevel']; final logLevel = LogLevel.values.firstWhere( - (e) => describeEnum(e).toUpperCase() == logLevelName, + (e) => e.name.toUpperCase() == logLevelName, orElse: () => LogLevel.info, ); final msg = args['message'];