Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/flutter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues with the SDK, please [open an issue on GitHub](https://github.com/superwall/superwall-flutter/issues).

<SdkLatestVersion version="2.4.5" repoUrl="https://github.com/superwall/Superwall-Flutter" />
<SdkLatestVersion version="2.4.6" repoUrl="https://github.com/superwall/Superwall-Flutter" />
19 changes: 16 additions & 3 deletions content/docs/flutter/quickstart/tracking-subscription-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ The `SubscriptionStatus` enum has three possible values:
- `SubscriptionStatus.active` - User has an active subscription
- `SubscriptionStatus.inactive` - User has no active subscription

Use the `isActive` convenience property when you only need to know if the user is subscribed:

```dart
Superwall.shared.subscriptionStatus.listen((status) {
if (status.isActive) {
_showPremiumContent();
} else {
_showFreeContent();
}
});
```

## Using SuperwallBuilder widget

For reactive UI updates based on subscription status, use the `SuperwallBuilder` widget:
Expand Down Expand Up @@ -100,13 +112,14 @@ class PremiumFeatureButton extends StatelessWidget {
stream: Superwall.shared.subscriptionStatus,
builder: (context, snapshot) {
final status = snapshot.data ?? SubscriptionStatus.unknown;
final isActive = status.isActive;

return ElevatedButton(
onPressed: status == SubscriptionStatus.active
onPressed: isActive
? _accessPremiumFeature
: _showPaywall,
child: Text(
status == SubscriptionStatus.active
isActive
? 'Access Premium Feature'
: 'Upgrade to Premium',
),
Expand All @@ -133,7 +146,7 @@ If you need to check the subscription status at a specific moment without listen
Future<void> checkSubscription() async {
// Note: You'll need to get the current value from the stream
final subscription = Superwall.shared.subscriptionStatus.listen((status) {
if (status == SubscriptionStatus.active) {
if (status.isActive) {
// User is subscribed
enablePremiumFeatures();
} else {
Expand Down
8 changes: 7 additions & 1 deletion content/docs/flutter/sdk-reference/PaywallOptions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PaywallOptions {
bool shouldShowWebRestorationAlert = true;
Map<String, String>? overrideProductsByName;
bool shouldShowWebPurchaseConfirmationAlert = true;
void Function(PaywallInfo?)? onBackPressed;
}

class RestoreFailed {
Expand Down Expand Up @@ -49,6 +50,7 @@ enum TransactionBackgroundView { spinner, none }
| `shouldShowWebRestorationAlert` | `bool` | Shows an alert asking the user to try restoring on the web if web checkout is enabled. Defaults to `true`. |
| `overrideProductsByName` | `Map<String, String>?` | Overrides products on all paywalls using name→identifier mapping (e.g., `"primary"` → `"com.example.premium_monthly"`). |
| `shouldShowWebPurchaseConfirmationAlert` | `bool` | Shows a localized alert confirming a successful web checkout purchase. Defaults to `true`. |
| `onBackPressed` | `void Function(PaywallInfo?)?` | Android only. Invoked when the system back button is pressed while a paywall is visible. Call `Superwall.shared.dismiss()` inside if you want to close the paywall. |
</ParamTable>

## Usage
Expand All @@ -64,7 +66,11 @@ final paywallOptions = PaywallOptions()
'tertiary': 'com.example.premium_annual',
}
..shouldShowWebRestorationAlert = true
..shouldShowWebPurchaseConfirmationAlert = true;
..shouldShowWebPurchaseConfirmationAlert = true
..onBackPressed = (paywallInfo) {
// Android-only callback
Superwall.shared.dismiss();
};

final options = SuperwallOptions(
paywalls: paywallOptions,
Expand Down
2 changes: 1 addition & 1 deletion content/docs/flutter/sdk-reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues with the SDK, please [open an issue on GitHub](https://github.com/superwall/superwall-flutter/issues).

<SdkLatestVersion version="2.4.5" repoUrl="https://github.com/superwall/Superwall-Flutter" />
<SdkLatestVersion version="2.4.6" repoUrl="https://github.com/superwall/Superwall-Flutter" />
15 changes: 15 additions & 0 deletions content/docs/flutter/sdk-reference/subscriptionStatus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ Stream<SubscriptionStatus> get subscriptionStatus
## Returns / State
Returns a `Stream<SubscriptionStatus>` that emits values whenever the subscription status changes.

## Convenience
Use the `isActive` convenience property when you only need to know whether the user is subscribed:

```dart
Future<void> ensureAccess() async {
final status = await Superwall.shared.subscriptionStatus.first;

if (status.isActive) {
enablePremiumFeatures();
} else {
showUpgradePrompt();
}
}
```

## Usage

Basic stream subscription:
Expand Down