Background
Get set up with the Helium SDK for Flutter. Reach out over your Helium slack channel or email founders@tryhelium.com for any questions.Installation
Runflutter pub add helium_flutter or manually add the helium_flutter package to your pubspec.yaml:
You can still use Cocoapods for your dependencies if preferred. If you need to disable Swift Package Manager dependencies after having enabled it, refer to that same Flutter documentation.
iOS Settings
Helium requires iOS 15+. If your app already has a minimum of iOS 15 or higher, you’re all set. This can be specified in yourios/Podfile with:
Initialize Helium
In your app’s initialization code (typically inmain.dart or your root widget), add the following to configure Helium and prepare your paywalls:
Custom User ID and Custom User Traits
Custom User ID and Custom User Traits
You can set a custom user ID and custom user traits with the
initialize method or by calling:Checking Download Status
Checking Download Status
After initialization, you can check the status of the paywalls download:The download status will be one of the following:
notDownloadedYet: The download has not been initiated.inProgress: The download has not been initiated.downloadSuccess: The download was successful.downloadFailure: The download failed.
await heliumFlutter.paywallsLoaded()Helium Events
To handle various paywall-related events, implementHeliumCallbacks and pass it to initialize:
Handling Purchases
By default, Helium will handle purchase logic for you. If you want a custom implementation, you’ll want to implementHeliumPurchaseDelegate and pass that into initialize.
Basic Implementation
Here’s a basic implementation ofHeliumPurchaseDelegate:
RevenueCat Implementation Example
Presenting Paywalls
There are two ways to show a Helium paywall in your Flutter app:Via Direct Method Call (Recommended)
You can present a paywall programmatically using thepresentUpsell method:
presentUpsell:
Via Widget Integration
You can also use theHeliumFlutter.getUpsellWidget method to embed a paywall directly in your widget tree:
You will have to handle your own dismissal in this case. You can do so by listening for the
paywallDismissed event in onPaywallEvent of your HeliumCallbacks implementation.Hiding Paywalls
To programmatically hide a paywall that was shown with thepresentUpsell method: