Skip to content

Commit 169a9f4

Browse files
feat: Update for Flutter SDK 2.4.6 (#65)
Co-authored-by: Cursor Agent <[email protected]>
1 parent 308978f commit 169a9f4

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

content/docs/flutter/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ If you have feedback on any of our docs, please leave a rating and message at th
3434

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

37-
<SdkLatestVersion version="2.4.5" repoUrl="https://github.com/superwall/Superwall-Flutter" />
37+
<SdkLatestVersion version="2.4.6" repoUrl="https://github.com/superwall/Superwall-Flutter" />

content/docs/flutter/quickstart/tracking-subscription-state.mdx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ The `SubscriptionStatus` enum has three possible values:
5454
- `SubscriptionStatus.active` - User has an active subscription
5555
- `SubscriptionStatus.inactive` - User has no active subscription
5656

57+
Use the `isActive` convenience property when you only need to know if the user is subscribed:
58+
59+
```dart
60+
Superwall.shared.subscriptionStatus.listen((status) {
61+
if (status.isActive) {
62+
_showPremiumContent();
63+
} else {
64+
_showFreeContent();
65+
}
66+
});
67+
```
68+
5769
## Using SuperwallBuilder widget
5870

5971
For reactive UI updates based on subscription status, use the `SuperwallBuilder` widget:
@@ -100,13 +112,14 @@ class PremiumFeatureButton extends StatelessWidget {
100112
stream: Superwall.shared.subscriptionStatus,
101113
builder: (context, snapshot) {
102114
final status = snapshot.data ?? SubscriptionStatus.unknown;
115+
final isActive = status.isActive;
103116
104117
return ElevatedButton(
105-
onPressed: status == SubscriptionStatus.active
118+
onPressed: isActive
106119
? _accessPremiumFeature
107120
: _showPaywall,
108121
child: Text(
109-
status == SubscriptionStatus.active
122+
isActive
110123
? 'Access Premium Feature'
111124
: 'Upgrade to Premium',
112125
),
@@ -133,7 +146,7 @@ If you need to check the subscription status at a specific moment without listen
133146
Future<void> checkSubscription() async {
134147
// Note: You'll need to get the current value from the stream
135148
final subscription = Superwall.shared.subscriptionStatus.listen((status) {
136-
if (status == SubscriptionStatus.active) {
149+
if (status.isActive) {
137150
// User is subscribed
138151
enablePremiumFeatures();
139152
} else {

content/docs/flutter/sdk-reference/PaywallOptions.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class PaywallOptions {
2222
bool shouldShowWebRestorationAlert = true;
2323
Map<String, String>? overrideProductsByName;
2424
bool shouldShowWebPurchaseConfirmationAlert = true;
25+
void Function(PaywallInfo?)? onBackPressed;
2526
}
2627
2728
class RestoreFailed {
@@ -49,6 +50,7 @@ enum TransactionBackgroundView { spinner, none }
4950
| `shouldShowWebRestorationAlert` | `bool` | Shows an alert asking the user to try restoring on the web if web checkout is enabled. Defaults to `true`. |
5051
| `overrideProductsByName` | `Map<String, String>?` | Overrides products on all paywalls using name→identifier mapping (e.g., `"primary"``"com.example.premium_monthly"`). |
5152
| `shouldShowWebPurchaseConfirmationAlert` | `bool` | Shows a localized alert confirming a successful web checkout purchase. Defaults to `true`. |
53+
| `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. |
5254
</ParamTable>
5355

5456
## Usage
@@ -64,7 +66,11 @@ final paywallOptions = PaywallOptions()
6466
'tertiary': 'com.example.premium_annual',
6567
}
6668
..shouldShowWebRestorationAlert = true
67-
..shouldShowWebPurchaseConfirmationAlert = true;
69+
..shouldShowWebPurchaseConfirmationAlert = true
70+
..onBackPressed = (paywallInfo) {
71+
// Android-only callback
72+
Superwall.shared.dismiss();
73+
};
6874
6975
final options = SuperwallOptions(
7076
paywalls: paywallOptions,

content/docs/flutter/sdk-reference/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ If you have feedback on any of our docs, please leave a rating and message at th
1515

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

18-
<SdkLatestVersion version="2.4.5" repoUrl="https://github.com/superwall/Superwall-Flutter" />
18+
<SdkLatestVersion version="2.4.6" repoUrl="https://github.com/superwall/Superwall-Flutter" />

content/docs/flutter/sdk-reference/subscriptionStatus.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ Stream<SubscriptionStatus> get subscriptionStatus
1818
## Returns / State
1919
Returns a `Stream<SubscriptionStatus>` that emits values whenever the subscription status changes.
2020

21+
## Convenience
22+
Use the `isActive` convenience property when you only need to know whether the user is subscribed:
23+
24+
```dart
25+
Future<void> ensureAccess() async {
26+
final status = await Superwall.shared.subscriptionStatus.first;
27+
28+
if (status.isActive) {
29+
enablePremiumFeatures();
30+
} else {
31+
showUpgradePrompt();
32+
}
33+
}
34+
```
35+
2136
## Usage
2237

2338
Basic stream subscription:

0 commit comments

Comments
 (0)