AndroidReplacementMode enum

Android Replacement Mode (formerly Proration Mode)

IMPORTANT: Replacement modes are ONLY for upgrading/downgrading EXISTING subscriptions. For NEW subscriptions, do NOT use any replacement mode.

To use replacement mode:

  1. User must have an active subscription
  2. You must provide the purchaseToken from the existing subscription
  3. Get the token using getAvailablePurchases()

Example:

// First, check for existing subscription
final purchases = await FlutterInappPurchase.instance.getAvailablePurchases();
if (purchases.isEmpty) {
  // User has no subscription - purchase new one WITHOUT replacement mode
  await FlutterInappPurchase.instance.requestPurchaseWithBuilder(
    build: (builder) {
      builder.type = ProductQueryType.Subs;
      builder.android.skus = ['premium_monthly'];
    },
  );
} else {
  // User has subscription - can upgrade/downgrade WITH replacement mode
  final existingSub = purchases.first;
  await FlutterInappPurchase.instance.requestPurchaseWithBuilder(
    build: (builder) {
      builder.type = ProductQueryType.Subs;
      builder.android
        ..skus = ['premium_yearly']
        ..purchaseTokenAndroid = existingSub.purchaseToken
        ..replacementModeAndroid =
            AndroidReplacementMode.withTimeProration.value;
    },
  );
}
Inheritance
Available extensions

Values

unknownReplacementMode → const AndroidReplacementMode
withTimeProration → const AndroidReplacementMode
chargeProratedPrice → const AndroidReplacementMode
withoutProration → const AndroidReplacementMode
deferred → const AndroidReplacementMode
chargeFullPrice → const AndroidReplacementMode

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int

Available on AndroidReplacementMode, provided by the AndroidReplacementModeValue extension

no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<AndroidReplacementMode>
A constant List of the values in this enum, in order of their declaration.