revenueCatDatasource function

  1. @Riverpod(keepAlive: true)
RevenueCatDatasource? revenueCatDatasource(
  1. Ref<Object?> ref
)

Native-only RevenueCat datasource. Returns null on web so the solo-user subscription screen can branch on platform and fall back to Stripe.

Implementation

@Riverpod(keepAlive: true)
RevenueCatDatasource? revenueCatDatasource(Ref ref) {
  if (kIsWeb) return null;
  if (_iosApiKey.isEmpty && _androidApiKey.isEmpty) {
    // No API key provided at build time — treat as unavailable. Useful during
    // local dev when the billing side is mocked.
    return null;
  }
  return RevenueCatDatasource(
    iosApiKey: _iosApiKey,
    androidApiKey: _androidApiKey,
  );
}