# Flutter

> Connect Dart and native mobile failures to one Flutter customer journey.

Canonical page: https://anectico.com/docs/instrument/flutter/


`anectico_flutter` bridges Dart to the native iOS and Android SDKs. Identity, sessions, persistence,
transport, and native crash handling remain in the native runtimes; the plugin adds Dart error
capture.

## Add and configure the plugin

During early access, use the source checkout supplied during onboarding, replacing this path:

```yaml
dependencies:
  anectico_flutter:
    path: /path/to/anectico/sdks/flutter
```

Run `flutter pub get`. After the public pub.dev release, replace the path dependency with the
published version constraint. For iOS,
enable Flutter's Swift Package Manager integration once with
`flutter config --enable-swift-package-manager`. The iOS deployment target is 15 or later.

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Anectico.configure(
    const AnecticoOptions(
      apiKey: 'an_...',
      environment: 'production',
      serviceVersion: '1.4.0',
    ),
  );
  runApp(const MyApp());
}
```

Use a project-scoped key with `ingest:write` and `analytics:write`. Do not include read, management,
or agent scopes in the application.

## Connect identity and events

```dart
await Anectico.identify('user_8842', set: {'plan': 'pro'});
await Anectico.group('company', 'acme', set: {'plan': 'enterprise'});
await Anectico.capture('checkout_completed', properties: {'total': 42});
await Anectico.screen('Checkout');

// On logout:
await Anectico.reset();
```

`reset` also clears global error-user context and buffered breadcrumbs, preventing
the prior account's diagnostic context from attaching to the next account on a
shared device.

`release`/`serviceVersion` above forward verbatim to the underlying native iOS/Android SDK, which
stamps the reserved `$release`/`$app_version` string properties on every captured event (not only
the automatic `$app_opened`). Neither is invented: omit them and events carry neither property.
See [Reserved event properties](/docs/investigate/event-schema#reserved-properties).

## Errors and crashes

`Anectico.configure` installs handlers for Flutter framework errors and uncaught asynchronous Dart errors
unless `enableDartErrorCapture` is false. Existing handlers remain chained.

```dart
try {
  await checkout();
} catch (error, stack) {
  await Anectico.captureError(
    error,
    stack,
    options: const CaptureOptions(tags: {'screen': 'cart'}),
  );
}
```

Native crashes use the underlying iOS and Android handlers. Upload their dSYM or ProGuard mapping.
Issue details identify Dart failures as `anectico-flutter / dart` and preserve their already-symbolic
`package:` frames without native artifact guidance. A Java/Kotlin, Swift, Objective-C, or signal
crash from the same Flutter application remains a native occurrence and still receives the relevant
ProGuard or dSYM status.

Each occurrence also inherits SDK-owned app/build, OS, and privacy-safe hardware-model context from
the native transport. Anectico never collects a stable device identifier or user-assigned device name.

Anectico does not currently symbolicate obfuscated Dart frames produced by `--obfuscate`; keep debug
information and use `flutter symbolize` out of band when that build mode is required.

## Propagate and shut down

`await Anectico.propagationHeaders()` returns W3C trace and customer baggage for trusted backend calls.
Call `await Anectico.flush()` before a test assertion and `await Anectico.shutdown()` when releasing the
runtime.

## Verify

Identify a test customer, capture a Dart error and event, and confirm both appear together. If iOS
fails to link the native package, confirm Swift Package Manager support is enabled and rebuild the
application rather than hot reloading.

- [Capture errors and releases](/docs/instrument/errors)
- [Flutter SDK API reference](/docs/reference/flutter-sdk)
- [Customer activity is not connecting](/docs/help/identity-not-linking)
