# Flutter

Add the Flutter source plugin for Aplyna's iOS StoreKit billing pilot, purchases, restores and entitlement checks, plus iOS/Android events and configuration.

## Install the plugin

Package: aplyna · version 1.0.1 on pub.dev. Import: package:aplyna/aplyna.dart. Requires Dart 3.5+ and Flutter 3.24+.

> **Preview distribution**
> Published on pub.dev. The plugin supports iOS 16+ and Android 23+; it does not declare web or desktop support. Rebuild your native app after installing.

- [Download Flutter SDK](https://aplyna.com/downloads/aplyna-flutter.zip): Dart API, platform channels and shared native source.

### Install

```
flutter pub add aplyna
```

### pubspec.yaml

```
dependencies:
  aplyna: ^1.0.1
```

> **iOS dependency setup**
> This preview includes a CocoaPods podspec, but not a Flutter Swift Package Manager manifest. Use your app's CocoaPods workflow for its iOS build. Flutter SPM support remains release work; the Swift SDK's own SPM package is separate.

## Send an event

### Dart

```
import 'package:aplyna/aplyna.dart';

final installationId = await Aplyna.configure(apiKey: 'YOUR_APP_SDK_KEY');
// Only after your application permits tracking:
await Aplyna.setConsent(true);
await Aplyna.track('app_opened');
await Aplyna.flush();
```

configure returns a persistent anonymous installation ID and starts with consent disabled. Pass installationId to retain an existing integration's identity. Await calls and handle PlatformException; flush again later after final delivery failures.

## Shared methods

Use setConsent, track, flush, pendingEventCount, assignment, expose and configuration. Track accepts flowId, stepId, an AplynaAssignment and string-valued properties. Call expose only when the assigned UI appears. Configuration is code-first data: schemas 1/2 on iOS and schema 1 on Android.

> **Current scope**
> Aplyna.billing is a separately configured iOS 16+ StoreKit pilot for purchase, restore, verified access, renewal/grace state and subscription management. Physical iOS Sandbox host checks have been recorded, with refund/pending limitations retained. A separate Android billing implementation remains unreleased under device validation. Visual rendering and cross-device merging are not exposed. Trial activity signals do not verify payments; analytics installations are separate from billing customers.

- [Add subscription billing](https://aplyna.com/docs/billing-quickstart): Configure the iOS pilot and check actual entitlement access.
