RevenueCatDatasource class

Native (iOS/Android) implementation of the RevenueCat client.

Selected via conditional import from revenuecat_datasource_barrel.dart: web builds resolve to the stub instead. Do NOT import this file directly.

All operations are thin wrappers over purchases_flutter. Configuration requires a RevenueCat public SDK key (one per platform). Subscription state is synced to our subscriptions table via the revenuecat-webhook Edge Function — not by polling this client.

The datasource tracks its own "configured" state to prevent a pre-configure native call. If callers dispatch to purchases_hybrid_common without a prior successful Purchases.configure, the iOS side raises a Swift fatalError (SIGTRAP) that Dart's try/catch cannot intercept — the process dies. Gating every method on isConfigured turns that into a clean Dart-land error the UI can render.

Constructors

RevenueCatDatasource({required String iosApiKey, required String androidApiKey, PurchasesApi? purchases})

Properties

hashCode int
The hash code for this object.
no setterinherited
isConfigured bool
True once configure has finished successfully. Native-calling methods bail out early when false so no getOfferings / purchasePackage request reaches the plugin before the SDK is ready.
no setter
ready Future<void>
Future that resolves when an in-flight configure has finished (successfully or not). Callers that need offerings or purchases should await rc.ready; before their first call so they don't race a background configure kicked off by the auth-state listener.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

configure({required String userId}) Future<void>
Initialize the Purchases SDK. Idempotent and concurrent-safe — a second call while the first is in flight awaits the same future. On failure the stored future is discarded so a later call (e.g. after sign-in retry) gets a fresh attempt instead of reusing the failed one.
getCustomerInfo() Future<CustomerInfo?>
Read the cached customer state (after configure + first fetch).
getOfferings() Future<Offerings?>
Fetch available subscription offerings (Professional monthly / annual). Returns null if RevenueCat is not yet configured or no offerings configured.
logOut() Future<void>
Log out of RevenueCat when the user signs out of DuTaTo. Clears the RevenueCat app_user_id so a subsequent sign-in doesn't inherit state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purchasePackage(Package package) Future<CustomerInfo>
Purchase a specific package. Throws on user cancellation so the UI can handle the error distinctly; returns the updated customer info on success. RevenueCat delivers the receipt to our backend via webhook — we do not validate here.
restorePurchases() Future<CustomerInfo>
Restore previous purchases on a new device. Required by Apple guidelines for any app that sells subscriptions.
toString() String
A string representation of this object.
inherited

Operators

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