---
title: "Flutter"
description: "Sentry's Flutter SDK enables automatic reporting of errors and performance data in your application."
url: https://docs.sentry.io/platforms/dart/guides/flutter/
---

# Flutter | Sentry for Flutter

On this page, we get you up and running with Sentry's Flutter SDK.

If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page.

## [Features](https://docs.sentry.io/platforms/dart/guides/flutter.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/explore/profiling.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## [Install](https://docs.sentry.io/platforms/dart/guides/flutter.md#install)

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Session Replay\[ ]Logs

Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works.

We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running one of the following commands inside your project directory:

```bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutter
```

This will patch your project and configure the SDK. You only need to patch the project once, then you can add the patched files to your version control system. If you prefer, you can also [set up the SDK manually](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md) or follow the instructions below to adapt the [configuration](https://docs.sentry.io/platforms/dart/guides/flutter.md#configure).

The following tasks will be performed by the Sentry Wizard

* Configure the SDK with your DSN and performance monitoring options in your main.dart file.
* Update your `pubspec.yaml` with the `sentry_flutter` and `sentry_dart_plugin` packages.
* Add an example error to verify your setup.

## [Configure](https://docs.sentry.io/platforms/dart/guides/flutter.md#configure)

Configuration should happen as early as possible in your application's lifecycle.

```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = '___PUBLIC_DSN___';
      // Adds request headers and IP for users, for more info visit:
      // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/
      options.sendDefaultPii = true;
      // ___PRODUCT_OPTION_START___ performance
      // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
      // We recommend adjusting this value in production.
      options.tracesSampleRate = 1.0;
      // ___PRODUCT_OPTION_END___ performance
      // ___PRODUCT_OPTION_START___ profiling
      // The sampling rate for profiling is relative to tracesSampleRate
      // Setting to 1.0 will profile 100% of sampled transactions:
      // Note: Profiling alpha is available for iOS and macOS since SDK version 7.12.0
      options.profilesSampleRate = 1.0;
      // ___PRODUCT_OPTION_END___ profiling
      // ___PRODUCT_OPTION_START___ logs

      // Enable logs to be sent to Sentry
      options.enableLogs = true;
      // ___PRODUCT_OPTION_END___ logs
      // ___PRODUCT_OPTION_START___ session-replay
      // Record session replays for 100% of errors and 10% of sessions
      options.replay.onErrorSampleRate = 1.0;
      options.replay.sessionSampleRate = 0.1;
      // ___PRODUCT_OPTION_END___ session-replay
    },
    appRunner: () => runApp(
      SentryWidget(
        child: MyApp(),
      ),
    ),
  );

  // you can also configure SENTRY_DSN, SENTRY_RELEASE, SENTRY_DIST, and
  // SENTRY_ENVIRONMENT via Dart environment variable (--dart-define)
}
```

## [Verify](https://docs.sentry.io/platforms/dart/guides/flutter.md#verify)

Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

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

try {
  throw StateError('Sentry Test Exception');
} catch (exception, stackTrace) {
  await Sentry.captureException(
    exception,
    stackTrace: stackTrace,
  );
}
```

## [Next Steps](https://docs.sentry.io/platforms/dart/guides/flutter.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup
* [Learn about the features of Sentry's Flutter SDK](https://docs.sentry.io/platforms/dart/guides/flutter/features.md)
* [Add readable stack traces to errors](https://docs.sentry.io/platforms/dart/guides/flutter/upload-debug.md#when-to-upload/)
* [Add performance instrumentation to your app](https://docs.sentry.io/platforms/dart/guides/flutter/tracing/instrumentation.md)

## Topics

- [Features](https://docs.sentry.io/platforms/dart/guides/flutter/features.md)
- [Manual Setup](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md)
- [Debug Symbols](https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols.md)
- [Basic Configuration](https://docs.sentry.io/platforms/dart/guides/flutter/configuration.md)
- [Usage](https://docs.sentry.io/platforms/dart/guides/flutter/usage.md)
- [Native Initialization](https://docs.sentry.io/platforms/dart/guides/flutter/native-init.md)
- [Integrations](https://docs.sentry.io/platforms/dart/guides/flutter/integrations.md)
- [Enriching Events](https://docs.sentry.io/platforms/dart/guides/flutter/enriching-events.md)
- [Data Management](https://docs.sentry.io/platforms/dart/guides/flutter/data-management.md)
- [Tracing](https://docs.sentry.io/platforms/dart/guides/flutter/tracing.md)
- [Profiling](https://docs.sentry.io/platforms/dart/guides/flutter/profiling.md)
- [Size Analysis](https://docs.sentry.io/platforms/dart/guides/flutter/size-analysis.md)
- [Build Distribution](https://docs.sentry.io/platforms/dart/guides/flutter/build-distribution.md)
- [Session Replay](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay.md)
- [Logs](https://docs.sentry.io/platforms/dart/guides/flutter/logs.md)
- [Metrics](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md)
- [User Feedback](https://docs.sentry.io/platforms/dart/guides/flutter/user-feedback.md)
- [Mobile SDK Releases](https://docs.sentry.io/platforms/dart/guides/flutter/releases.md)
- [Set Up Feature Flags](https://docs.sentry.io/platforms/dart/guides/flutter/feature-flags.md)
- [SDK Overhead](https://docs.sentry.io/platforms/dart/guides/flutter/overhead.md)
- [Migration Guide](https://docs.sentry.io/platforms/dart/guides/flutter/migration.md)
- [Troubleshooting](https://docs.sentry.io/platforms/dart/guides/flutter/troubleshooting.md)
