This file provides guidance to AI coding agents when working with code in this repository.
Adapty Flutter SDK (adapty_flutter) — a Flutter plugin for in-app subscriptions, paywalls, and onboardings via Adapty's backend. Supports iOS (15.0+) and Android (SDK 21+).
# Run tests (only the example app has tests)
cd example && flutter test
# Analyze Dart code
flutter analyze
# Get dependencies
flutter pub get
# Build example app
cd example && flutter build ios --no-codesign
cd example && flutter build apkThere is no custom Makefile, CI config, or lint script in this repo. The linting config is minimal — analysis_options.yaml sets max line length to 120.
The SDK is a standard Flutter plugin using MethodChannel (flutter.adapty.com/adapty) for Dart↔Native communication:
- Dart side:
lib/src/adapty.dart— singletonAdaptyclass with all public API methods.AdaptyUIis defined viapart 'adaptyui.dart'in the same library. - Android side:
android/src/main/kotlin/com/adapty/flutter/AdaptyFlutterPlugin.kt— bridges to the native Android Adapty SDK (dependency via BOM inandroid/build.gradle). - iOS side:
ios/adapty_flutter/Sources/adapty_flutter/SwiftAdaptyFlutterPlugin.swift— bridges to the native iOS Adapty SDK (dependency via Swift Package Manager inios/adapty_flutter/Package.swift). iOS is SPM-only as of 4.0.0 (no podspec).
All method names and argument keys are centralized in lib/src/constants/method.dart and lib/src/constants/argument.dart.
cross_platform.yaml (root) is a JSON Schema defining the request/response contract between Dart and native code. When adding or changing a method, this schema should stay in sync.
All data models live in lib/src/models/. Each model has a corresponding *JSONBuilder in lib/src/models/private/ that handles JSON serialization/deserialization. The base helpers (Map<String, dynamic> extensions for typed access) are in lib/src/models/private/json_builder.dart.
Public exports are controlled via lib/adapty_flutter.dart using explicit show clauses.
Observer interfaces (AdaptyUIPaywallsEventsObserver, AdaptyUIOnboardingsEventsObserver) in lib/src/adaptyui_observer.dart handle native→Dart callbacks. Event routing goes through lib/src/adaptyui_events_proxy.dart. Profile updates use a broadcast StreamController.
Native paywall and onboarding views are embedded via PlatformView widgets in lib/src/platform_views/. Corresponding native view factories are in the Android/iOS directories.
- Singletons:
Adapty()andAdaptyUI()are singleton factories. - Builders: Configuration objects use the builder pattern (
AdaptyConfigurationBuilder,AdaptyProfileParametersBuilder,AdaptyPurchaseParametersBuilder). - JSON round-trip: Native calls return
Map<String, dynamic>decoded from JSON. Models are constructed from these maps via their JSON builders; outgoing data usesjsonValuegetters.
- Use conventional commits:
feat:,fix:,refactor:,chore:,docs:,test:, etc. - Do not add "Co-Authored-By" lines to commit messages.
Version bumps require updating multiple files in lockstep:
pubspec.yaml— Dart package versionandroid/build.gradle— Android native SDK BOM version and crossplatform versionios/adapty_flutter/Package.swift— iOS native SDK dependency (SPM; pin moves in lockstep)CHANGELOG.md