daybook_subscriptions 0.10.0
daybook_subscriptions: ^0.10.0 copied to clipboard
Purchases for Flutter on Daybook: StoreKit 2 and Google Play Billing subscriptions that are never lost, access you can check, and paywalls as data.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'customer_page.dart';
/// Daybook subscriptions, run by hand.
///
/// Run with your app's key from Subscriptions › Settings › SDK keys:
/// flutter run --dart-define=SDK_KEY=pms_...
/// and, for a local API, --dart-define=API_URL=http://localhost:5099. PRODUCT_IDS names what the
/// store section offers, comma-separated; it defaults to `ios/RunnerTests/Products.storekit`'s.
/// PLACEMENT is the placement the paywall section asks for.
///
/// On Android, PRODUCT_IDS are Google Play's `productId:basePlanId`. A license tester buys an app's real
/// products in this debug build when it is built as that app's package (PM-T-0739):
/// ORG_GRADLE_PROJECT_exampleApplicationId=com.example.app flutter run --dart-define=SDK_KEY=pms_... \
/// --dart-define=PRODUCT_IDS=premium:monthly
const _sdkKey = String.fromEnvironment('SDK_KEY');
const _apiUrl = String.fromEnvironment('API_URL');
const _productIds = String.fromEnvironment('PRODUCT_IDS', defaultValue: 'premium.monthly,premium.lifetime,coins.100');
const _placement = String.fromEnvironment('PLACEMENT', defaultValue: 'onboarding');
void main() => runApp(const SubscriptionsExample());
class SubscriptionsExample extends StatelessWidget {
const SubscriptionsExample({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Daybook subscriptions example',
theme: ThemeData(colorSchemeSeed: Colors.indigo),
darkTheme: ThemeData(colorSchemeSeed: Colors.indigo, brightness: Brightness.dark),
home: CustomerPage(sdkKey: _sdkKey, baseUrl: _apiUrl.isEmpty ? null : Uri.parse(_apiUrl), productIds: _productIds.split(','), placementId: _placement),
);
}