getProducts static method

Future<List<StoreProduct>> getProducts(
  1. List<String> productIdentifiers, {
  2. ProductCategory productCategory = ProductCategory.subscription,
  3. @Deprecated('Use ProductType') PurchaseType type = PurchaseType.subs,
})

Fetch the product info. Returns a list of products or throws an error if the products are not properly configured in RevenueCat or if there is another error while retrieving them.

productIdentifiers Array of product identifiers

productCategory If the products are Android INAPPs, this needs to be ProductCategory.nonSubscription otherwise the products won't be found. ProductCategory.subscription by default. This parameter only has effect in Android.

type If the products are Android INAPPs, this needs to be PurchaseType.inapp otherwise the products won't be found. PurchaseType.subs by default. This parameter only has effect in Android.

Implementation

static Future<List<StoreProduct>> getProducts(
  List<String> productIdentifiers, {
  ProductCategory productCategory = ProductCategory.subscription,
  @Deprecated('Use ProductType') PurchaseType type = PurchaseType.subs,
}) async {
  // Use deprecated PurchasesType if using something other than default
  // Otherwise use new ProductType
  String typeString;
  // ignore: deprecated_member_use_from_same_package
  if (type != PurchaseType.subs) {
    typeString = type.name;
  } else {
    typeString = productCategory.name;
  }

  final List<dynamic> result = await _channel.invokeMethod('getProductInfo', {
    'productIdentifiers': productIdentifiers,
    'type': typeString,
  });
  return result
      .map<StoreProduct>(
        (item) => StoreProduct.fromJson(
          Map<String, dynamic>.from(item),
        ),
      )
      .toList();
}