type property

ProductQueryType get type

Implementation

ProductQueryType get type => _type;
set type (Object value)

Implementation

set type(Object value) {
  if (value is ProductQueryType) {
    if (value == ProductQueryType.All) {
      throw ArgumentError(
        'ProductQueryType.All is not supported in RequestPurchaseBuilder. '
        'Use RequestSubscriptionBuilder or specify ProductType.InApp/ProductType.Subs explicitly.',
      );
    }
    _type = value;
    return;
  }
  if (value is ProductType) {
    _type = value == ProductType.InApp
        ? ProductQueryType.InApp
        : ProductQueryType.Subs;
    return;
  }
  if (value is String) {
    switch (value.trim().toLowerCase()) {
      case 'in-app':
        _type = ProductQueryType.InApp;
        return;
      case 'subs':
        _type = ProductQueryType.Subs;
        return;
      default:
        throw ArgumentError(
          'Unsupported purchase type: $value. Use in-app or subs.',
        );
    }
  }
  throw ArgumentError('Unsupported type assignment: $value');
}