Skip to content

Entitlements

The entitlements system in ShipFlutter manages user subscriptions and purchases across different payment providers. It integrates with RevenueCat for mobile platforms and LemonSqueezy for web.

What are Entitlements?

An entitlement represents a user’s access to premium features. It includes:

class Entitlement {
final String id; // Unique identifier
final String productId; // Product identifier from store
final PaymentStoreId storeId; // RevenueCat or LemonSqueezy
final DateTime? expiresAt; // Subscription expiry
final DateTime? unsubscribedAt; // Cancellation date
final DateTime? billingIssueAt; // Payment issues
final bool isTrial; // Trial period
final bool willRenew; // Auto-renewal status
final bool isActive; // Current access status
}

The concept comes from RevenueCat’s Entitlements. We simplified and aligned it with LemonSqueezy’s Subscriptions.

Syncing Entitlements

The AccountService automatically syncs entitlements with the user’s account:

  1. Listens to payment provider events
  2. Updates local entitlements state
  3. Syncs with Firestore database
  4. (Optional) Updates user’s custom claims
// Observe account changes including entitlements
accountService.instance.observeAccount().listen((account) {
final entitlements = account?.entitlements ?? [];
// Handle entitlement changes
});

In addition, you can configure RevenueCat and/or LemonSqueezy webhooks to sync entitlements with the server.