stubkit docs

Flutter quickstart

stubkit's Flutter SDK wraps the in_app_purchase plugin. This guide gets you from zero to a working paywall in 15 minutes.

Install

# pubspec.yaml — install via git reference
dependencies:
  stubkit:
    git:
      url: https://github.com/stubkithq/stubkit-flutter
      ref: v1.0.1
  in_app_purchase: ^3.1.11

Configure

// main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await StubkitPurchases.instance.configure(
    apiKey: 'pk_live_...',
    appId: 'notesam',
    userId: currentUser.id,
  );
  runApp(MyApp());
}

Show the paywall

Navigator.of(context).push(MaterialPageRoute(
  builder: (_) => StubkitPaywall(
    apiKey: 'pk_live_...',
    appId: 'notesam',
    slug: 'default',
    onOutcome: (outcome) {
      if (outcome == PaywallOutcome.purchased) Navigator.pop(context);
    },
  ),
));

Check entitlements

final isPro = await EntitlementCache.instance.isActive(
  appId: 'notesam',
  userId: userId,
  entitlementId: 'pro',
);

Restore purchases

await StubkitPurchases.instance.restore();

Next steps