Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io
    Get started
    Flutter
    Beginner
    31 min

    Add a paywall and subscriptions to a Flutter app

    To add a paywall to a Flutter app with BillDog, add billdog_flutter, set iOS 15 and Android minSdk 24, call BillDog.configure(apiKey) in main(), then await BillDog.shared.register('onboarding') where the paywall belongs. The same Dart code sells through the App Store and Google Play, and getCustomerInfo() tells you whether to unlock.

    Steps last checked against the SDK source on 15 Nov 2026.

    What you'll build

    • One Dart code path that shows a paywall on iOS and Android
    • Content gated on the premium entitlement
    • Restore Purchases wired to the result type

    What you'll need

    1. Install the package

    2 min
    Terminal
    flutter pub add billdog_flutter:^1.2.0-beta.1

    Or add it to pubspec.yaml yourself:

    pubspec.yaml
    dependencies:
      billdog_flutter: ^1.2.0-beta.1

    2. Raise the platform minimums

    2 min

    The Flutter template targets iOS 13. BillDog needs iOS 15 and Android minSdk 24; without these, pod install fails on the iOS deployment target and the Android build fails on minSdk.

    ios/Podfile
    platform :ios, '15.0'

    Also set iOS Deployment Target to 15.0 on the Runner target in Xcode, so the app and the pods agree. With Swift Package Manager enabled there may be no Podfile at all, but the Runner target still needs 15.0.

    android/app/build.gradle.kts
    android {
        defaultConfig {
            minSdk = 24
        }
    }

    3. Set up the product, paywall and placement

    12 min

    Your app asks BillDog for a placement (a named moment such as onboarding), and the dashboard decides which paywall to show there. That means you can change the paywall later without shipping an app update. Four things need to be connected: a product, an entitlement it grants, an offering that sells it, and a placement that serves the offering's paywall.

    1. Use the Public Sandbox API Key shown when you created the project. It starts with bd_public_test_. Didn't save it? The API Keys list shows only a prefix, so make a new one: open Integration & Data → API Keys, click Generate API Key, enter a Key Name, choose Environment: Sandbox and Key Type: Public (Client), then copy the key from the dialog. It is shown only once. Ship only public keys in an app; bd_secret_ keys are for servers.
    2. Open Monetization → Products and click New Product. Keep Product Kind: Store. The Product Identifier is BillDog's own ID for the product. Set Product Type to Subscription and choose a Subscription Duration. Put the exact store IDs in App Store Product ID and Play Store Product ID. A product with no ID for a store is not served on that platform. Enable Web Checkout is on by default; its price is only used for Stripe on the web. Products not in the store yet? See App Store setup or Google Play setup.
    3. Open Monetization → Entitlements, click New Entitlement, use the identifier premium (with any Display Name), and under Product Mapping tick the product. New projects also come with a pro entitlement and a Default Offering; this codelab uses its own. Without this mapping a purchase succeeds but unlocks nothing.
    4. Open Monetization → Offerings, click New Offering, give it an Identifier and Display Name, tick Mark as current offering and click Create Offering. The offering editor opens: click Add Product, tick your product, type a Package Identifier such as monthly, click Add Package, then Save Changes.
    5. Open Paywalls & Funnels → Create New → Single Paywall, choose Use Template and pick one. In the builder, open the Products panel (the box icon in the left rail) and choose your offering under Offering.
    6. Templates are designs: their buttons aren't wired to buy anything. Select the main button, and under Tap Actions click Add First Action and choose Purchase. Give the close button (or a secondary button) a Close Paywall action if it has none: publishing refuses a paywall with no way out.
    7. Click Publish (then Save & Publish). A warning that "nothing on this paywall starts a purchase" means the main button still has no Purchase action. Check the paywall shows Live under Paywalls & Funnels → All Paywalls. An unpublished paywall serves nothing.
    8. Open Monetization → Placements, click Create Placement, set the Identifier to onboarding and a Display Name, and click Create. Then click the link icon on the placement's row, tick your offering, tick Default and click Link Offerings.
    9. In the same Create Placement dialog (or later on the placement's page), turn on Requires access and choose premium as the Required Entitlement. Subscribers then skip the paywall instead of seeing it again.

    Placement identifiers are case-sensitive. A mistyped identifier is created as an empty placement (you'll see it under Placements), and register comes back with a "no paywall configured" error. If nothing shows, see Fix a paywall that doesn't show.

    4. Configure the SDK in main()

    2 min

    The API key is a positional argument. After configure completes, use BillDog.shared everywhere else.

    lib/main.dart
    import 'package:flutter/material.dart';
    import 'package:billdog_flutter/billdog_flutter.dart';
    
    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await BillDog.configure(
        'bd_public_test_YOUR_KEY',
        options: const BillDogOptions(enableLogging: true),
      );
      runApp(const MyApp());
    }

    5. Show the paywall for a placement

    5 min

    register returns a sealed PlacementResult, so a Dart 3 switch covers every case. It returns PlacementError instead of throwing.

    Dart
    Future<void> showPaywall() async {
      final result = await BillDog.shared.register('onboarding');
      switch (result) {
        case PlacementPurchased() || PlacementEntitled() || PlacementRestored():
          setState(() => isPro = true);
        case PlacementError(:final message):
          debugPrint('Placement failed: $message');
        default:
          break; // PlacementDismissed, PlacementHoldout, PlacementOAuthSuccess
      }
    }

    6. Unlock content with the entitlement

    3 min
    Dart
    Future<void> refreshAccess() async {
      try {
        final info = await BillDog.shared.getCustomerInfo();
        setState(() => isPro = info.hasEntitlement('premium'));
      } catch (e) {
        // A BillDogError, or a StateError if the native plugin is missing
        debugPrint('Could not read entitlements: $e');
        setState(() => isPro = false); // treat errors as locked
      }
    }

    Call this on startup, for example from initState, so returning subscribers are unlocked before they reach a paywall.

    7. Add Restore Purchases

    3 min
    Dart
    final r = await BillDog.shared.restorePurchases();
    switch (r) {
      case RestoredItems(:final items):
        debugPrint('Restored ${items.length}');
      case RestoreFailed(:final error):
        debugPrint('Restore failed: ${error.message}');
    }
    final info = await BillDog.shared.getCustomerInfo(
      policy: CacheFetchPolicy.fetchCurrent,
    );
    setState(() => isPro = info.hasEntitlement('premium'));

    CacheFetchPolicy.fetchCurrent skips the cache so the UI shows the restored state straight away.

    8. Optional: identify signed-in users

    2 min

    An anonymous ID is created on first launch. Identify users when they sign in so purchases follow them across devices.

    Dart
    await BillDog.shared.identify('user_123');
    
    // On sign-out
    await BillDog.shared.logOut();

    Before release, switch to your bd_public_live_ key. To buy in the store sandboxes, see iOS sandbox testing and Google Play testing.

    Frequently asked questions

    billdog_flutter on pub.dev. It needs Dart 3 and Flutter 3.10 or later.

    iOS 15.0 and Android minSdk 24. Set platform :ios, '15.0' in ios/Podfile and minSdk = 24 in android/app/build.gradle.kts.

    No. register returns a PlacementError with a message instead of throwing. Note that BillDog.shared itself throws a StateError if you use it before BillDog.configure has completed, so configure in main() before runApp.

    Reference

    Ship it on a free project

    Create a project, grab your SDK key and follow along. Sandbox purchases and data stay separate from production, so test transactions never mix with real revenue.

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.