---
url: https://simpledatalogs.com/docs/quickstarts/flutter.md
description: >-
  Add simpledatalogs to a Flutter app with the simpledatalogs_flutter package,
  with launches, sessions, errors and screen views captured by one argument.
---

# Flutter

## Install

```sh
flutter pub add simpledatalogs_flutter
```

Until the package is on pub.dev, add it from GitHub as shown in the [Flutter SDK](/sdks/flutter#install) page.

## Add it

```dart
// lib/main.dart
import 'package:flutter/material.dart';
import 'package:simpledatalogs_flutter/simpledatalogs_flutter.dart';

Future<void> main() async {
  await SimpleDataLogsFlutter.configure(
    ingestKey: const String.fromEnvironment('SIMPLEDATALOGS_KEY'),
    autocapture: AutocaptureOptions.all,
  );

  runApp(MaterialApp(
    navigatorObservers: [SimpleDataLogsNavigatorObserver()],
    home: const HomePage(),
  ));
}
```

```dart
// Anywhere:
SimpleDataLogs.track('signup', {'plan': 'pro'});
```

Run with `flutter run --dart-define=SIMPLEDATALOGS_KEY=sdl_pub_…`. Events wait in a crash-safe outbox until a `202`, so nothing is lost if the app is killed.

## Send everything, or only what you choose

* **Everything:** `AutocaptureOptions.all` sends launches, sessions and uncaught errors.
* **Pick:** `AutocaptureOptions(sessions: true, errors: true)`.
* **Only your own events:** leave `autocapture` out.

## In the first minute

* `session_start` and `app_launched` within 10 seconds (5 in debug builds), or as soon as the app is hidden.
* A `screen_view` for every named route you open.
* With `SimpleDataLogs.setDeviceId(anonymousId)` before `configure`, the device counts in **active devices**.

## Autocapture defaults

| Option | With `AutocaptureOptions.all` |
|---|---|
| `appLaunches` | on |
| `sessions` (30 minutes away ends one) | on |
| `errors` (uncaught Flutter and platform errors, as `app_error`) | on |
| Screen views | named page routes, with `SimpleDataLogsNavigatorObserver` |

Dart servers use the pure Dart package. Everything else is in the [Flutter SDK](/sdks/flutter) reference.
