blob: 47bcf616fa40d9f1a30a57e2b282b1d3d2c06287 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
import '../../store_kit_wrappers.dart';
/// The class represents the information of a product as registered in the Apple
/// AppStore.
class AppStoreProductDetails extends ProductDetails {
/// Creates a new AppStore specific product details object with the provided
/// details.
AppStoreProductDetails({
required super.id,
required super.title,
required super.description,
required super.price,
required super.rawPrice,
required super.currencyCode,
required this.skProduct,
required super.currencySymbol,
});
/// Generate a [AppStoreProductDetails] object based on an iOS [SKProductWrapper] object.
factory AppStoreProductDetails.fromSKProduct(SKProductWrapper product) {
return AppStoreProductDetails(
id: product.productIdentifier,
title: product.localizedTitle,
description: product.localizedDescription,
price: product.priceLocale.currencySymbol + product.price,
rawPrice: double.parse(product.price),
currencyCode: product.priceLocale.currencyCode,
currencySymbol: product.priceLocale.currencySymbol.isNotEmpty
? product.priceLocale.currencySymbol
: product.priceLocale.currencyCode,
skProduct: product,
);
}
/// Points back to the [SKProductWrapper] object that was used to generate
/// this [AppStoreProductDetails] object.
final SKProductWrapper skProduct;
}