getAlreadyPurchasedList method

  1. @override
Future<List<ProductDetails>?> getAlreadyPurchasedList(
  1. List<String> purchase_ids,
  2. String purchase_type,
  3. PurchaseListener? listener
)
override

Implementation

@override
Future<List<ProductDetails>?> getAlreadyPurchasedList(
    List<String> purchase_ids,
    String purchase_type,
    PurchaseListener? listener) async {
  this.listener = listener;
  final List<PurchaseId> pricingList = [];

  purchase_ids.forEach((element) {
    pricingList
        .add(PurchaseId(purchaseId: element, purchaseType: purchase_type));
  });
  final List<ProductDetails> retrievePricingList = [];
  final list = await methodChannel.invokeMethod<String?>('getAlreadyPurchasedList',
      {"purchases": purchaseIdToJson(pricingList)});
  if ((list ?? "").isEmpty) {
    return List.empty();
  }
  productDetailsResponseFromJson(list!).forEach((element) {
    if ((element.zza ?? "").isNotEmpty) {
      retrievePricingList.add(productDetailsFromJson(element.zza!));
    }
  });

  return retrievePricingList;
}