getProducts method
Get the PurchaseProduct with its contents included.
Specify a callback to retrieve the user ID in onRetrieveUserId.
中身が含められたPurchaseProductを取得します。
onRetrieveUserIdにユーザーIDを取得するためのコールバックを指定します。
Implementation
@override
Future<List<PurchaseProduct>> getProducts({
required String? Function() onRetrieveUserId,
}) async {
final res = products.mapAndRemoveEmpty<PurchaseProduct>((e) {
switch (e.type) {
case PurchaseProductType.consumable:
return StoreConsumablePurchaseProduct(
product: e,
onRetrieveUserId: consumablePurchaseDelegate?.onRetrieveUserId ??
onRetrieveUserId,
onRetrieveDocument:
consumablePurchaseDelegate?.onRetrieveDocument ??
StoreConsumablePurchaseProduct.defaultOnRetrieveDocument,
onRetrieveValue: consumablePurchaseDelegate?.onRetrieveValue ??
StoreConsumablePurchaseProduct.defaultOnRetrieveValue,
onSaveDocument: consumablePurchaseDelegate?.onSaveDocument ??
StoreConsumablePurchaseProduct.defaultOnSaveDocument,
adapter: modelAdapter,
);
case PurchaseProductType.nonConsumable:
return StoreNonConsumablePurchaseProduct(
product: e,
onRetrieveUserId: nonConsumablePurchaseDelegate?.onRetrieveUserId ??
onRetrieveUserId,
onRetrieveDocument:
nonConsumablePurchaseDelegate?.onRetrieveDocument ??
StoreNonConsumablePurchaseProduct.defaultOnRetrieveDocument,
onRetrieveValue: nonConsumablePurchaseDelegate?.onRetrieveValue ??
StoreNonConsumablePurchaseProduct.defaultOnRetrieveValue,
onSaveDocument: nonConsumablePurchaseDelegate?.onSaveDocument ??
StoreNonConsumablePurchaseProduct.defaultOnSaveDocument,
adapter: modelAdapter,
);
case PurchaseProductType.subscription:
return StoreSubscriptionPurchaseProduct(
product: e,
onRetrieveUserId: subscriptionPurchaseDelegate?.onRetrieveUserId ??
onRetrieveUserId,
onRetrieveCollection: subscriptionPurchaseDelegate
?.onRetrieveCollection ??
StoreSubscriptionPurchaseProduct.defaultOnRetrieveCollection,
onRetrieveValue: subscriptionPurchaseDelegate?.onRetrieveValue ??
StoreSubscriptionPurchaseProduct.defaultOnRetrieveValue,
onSaveDocument: subscriptionPurchaseDelegate?.onSaveDocument ??
StoreSubscriptionPurchaseProduct.defaultOnSaveDocument,
onRevokeDocument: subscriptionPurchaseDelegate?.onRevokeDocument ??
StoreSubscriptionPurchaseProduct.defaultOnRevokeDocument,
adapter: modelAdapter,
);
case PurchaseProductType.subscriptionOffer:
return null;
}
});
await Future.wait(res.map((e) => e.load()));
return res;
}