DEV Community

Codexlancers
Codexlancers

Posted on

FlutterFlow + RevenueCat: Complete Guide to Subscription Apps


Introduction
If youโ€™re building a SaaS or premium mobile app, subscriptions are one of the most reliable monetization models.

But implementing subscriptions correctly is not just about adding a payment button โ€” it involves:

  • Secure validation
  • Real-time status updates
  • Handling edge cases (expiry, restore, refunds) In this guide, Iโ€™ll walk you through how I implemented a production-ready subscription system using FlutterFlow + RevenueCat + Firebase.

๐Ÿ’ฐ Why RevenueCat?
Instead of directly handling App Store / Play Store billing, I used RevenueCat because it simplifies everything.

Key Benefits:

  • โœ… Single integration for both iOS & Android
  • โœ… Handles receipts, validation, and renewals
  • โœ… Real-time subscription status via webhooks
  • โœ… Reduces development complexity ๐Ÿ‘‰ Without RevenueCat, managing subscriptions manually becomes very complex.

๐Ÿ—๏ธ System Architecture (Simple View)
Hereโ€™s how the system works:

  • FlutterFlow App (Frontend)
    โ†’ User interacts with UI (Upgrade, Restore)

  • RevenueCat SDK
    โ†’ Handles purchase flow

  • RevenueCat Server
    โ†’ Validates transactions

  • Firebase (Firestore + Cloud Functions)
    โ†’ Stores subscription status & triggers updates

๐Ÿ”„ Complete Subscription Flow
Hereโ€™s the exact flow I implemented:

1. User Action
User clicks โ€œUpgrade to Premiumโ€

2. Purchase Trigger
RevenueCat SDK opens native purchase screen (App Store / Play Store)

3. Payment Processing
Payment handled securely by Apple/Google
RevenueCat validates purchase
4. Webhook Trigger
RevenueCat sends event โ†’ Firebase Cloud Function

5. Firestore Update
User document is updated:

{
"isPremium": true,
"plan": "monthly",
"expiryDate": "timestamp"
}
Enter fullscreen mode Exit fullscreen mode

6. UI Update

  • FlutterFlow listens to Firestore
  • Premium features unlock instantly ๐Ÿงพ Firestore Database Structure To keep things scalable and clean, I used this structure:

๐Ÿ”น users collection

{
"userId": "123",
"isPremium": true,
"plan": "yearly",
"expiryDate": "timestamp"
}

Enter fullscreen mode Exit fullscreen mode

๐Ÿ”น subscriptions collection

{
"planId": "monthly_001",
"price": 9.99,
"duration": "1 month"
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”น events collection (VERY IMPORTANT)

{
"userId": "123",
"eventType": "PURCHASE",
"timestamp": "server_time"
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ‘‰ This helps in:

  • Tracking revenue
  • Debugging issues
  • Analytics โš ๏ธ Handling Edge Cases (Most Developers Miss This) This is where most apps fail โŒ

1. Expired Subscription

  • Check expiryDate regularly
  • Disable premium access automatically
    2. Restore Purchases

  • Add Restore button

  • Sync with RevenueCat

  • Update Firestore again

3. Cancelled Subscription

  • User cancels from App Store
  • RevenueCat webhook updates backend
  • Access removed after expiry
    4. Refunds

  • RevenueCat sends refund event

  • Immediately update user access
    ๐Ÿ” Backend Validation (CRITICAL)
    Never trust frontend logic โŒ


Always validate subscription from backend using:

  • RevenueCat webhooks
  • Firebase Cloud Functions
    ๐Ÿ‘‰ Why?

  • Prevents fake unlock hacks

  • Ensures real subscription status

  • Keeps your app secure
    โšก Performance & Cost Optimization
    Hereโ€™s what I optimized:

๐Ÿ”น Avoid Excessive Reads

  • Store only required subscription fields
  • Donโ€™t fetch full history every time
    ๐Ÿ”น Use Real-Time Listeners Smartly

  • Listen only to user document

  • Avoid unnecessary listeners
    ๐Ÿ”น Cache Subscription Status

  • Reduce repeated API calls
    ๐ŸŽฏ UI Best Practices (Conversion Focused)
    Subscription UI is not just design โ€” it impacts revenue ๐Ÿ’ฐ

What worked for me:

  • Highlight best plan (yearly)
  • Show discount badge (Save 30%)
  • Clear CTA: โ€œUpgrade Nowโ€
  • Add trust elements (secure payment, cancel anytime)

๐Ÿš€ Final Result
After implementing this system:

  • โœ… Smooth and secure purchase flow
  • โœ… Real-time subscription updates
  • โœ… Scalable backend architecture
  • โœ… Reduced bugs and edge case failures

๐Ÿ’ก Final Thoughts
FlutterFlow + RevenueCat is a powerful combination for building subscription-based apps quickly.

But the real difference comes from:

  • Proper backend validation
  • Clean database design
  • Handling real-world edge cases ๐Ÿ‘‰ Thatโ€™s what turns a basic app into a production-ready SaaS product.

Top comments (0)