Superwall.shared
The shared Superwall instance that provides access to all SDK methods.
You must call configure()
before accessing Superwall.shared
, or the app will crash.
Purpose
Provides access to the configured Superwall instance after calling configure()
.
Signature
static Superwall get shared
Returns / State
Returns the configured Superwall
instance that can be used to access all SDK methods.
Usage
Accessing the shared instance:
// After calling configure()
await Superwall.shared.registerPlacement('premium_feature');
await Superwall.shared.identify('user_123');
Common usage pattern:
void _upgradeUser() async {
await Superwall.shared.registerPlacement(
'upgrade_prompt',
feature: () {
// Feature unlocked after purchase
Navigator.pushNamed(context, '/premium-content');
},
);
}
With subscription status:
class _MyWidgetState extends State<MyWidget> {
@override
void initState() {
super.initState();
// Listen to subscription status changes
Superwall.shared.subscriptionStatus.listen((status) {
setState(() {
// Update UI based on subscription status
});
});
}
}
How is this guide?