---
title: "Manual Setup"
description: "Learn how to manually set up Sentry in your Flutter app, capture your first events, and view them in Sentry."
url: https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup/
---

# Manual Setup for Flutter

Looking for automatic setup with the Flutter wizard? Follow the [Flutter Quick Start](https://docs.sentry.io/platforms/dart/guides/flutter.md) instead. Continue with this guide to set up the SDK manually.

## [Prerequisites](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#prerequisites)

These instructions use Sentry Flutter SDK v10. You need:

* A Sentry [account](https://sentry.io/signup/) and [project](https://docs.sentry.io/product/projects.md)
* A Flutter application using **Flutter 3.44.0** and **Dart 3.12.0** or later
* **Android API 24** or later for Android apps, which is Flutter's default `minSdk`
* **iOS 15.0** or **macOS 12.0** or later for Apple apps, with Swift Package Manager enabled

For an existing Sentry integration, review the [migration guide](https://docs.sentry.io/platforms/dart/guides/flutter/migration.md) before upgrading to v10.

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

Add the Sentry Flutter SDK to your `pubspec.yaml`:

```yml
dependencies:
  sentry_flutter: ^10.6.0
```

### [Apple Platform Setup](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#apple-platform-setup)

The Flutter plugin installs the native Sentry SDK through Swift Package Manager. CocoaPods is not supported for this plugin.

Flutter 3.44 enables Swift Package Manager by default and migrates the Xcode project when you run your app. If you previously disabled it, remove any project-level `enable-swift-package-manager: false` setting and run:

```bash
flutter config --enable-swift-package-manager
flutter pub get
```

Set your Xcode deployment targets to iOS 15.0 or macOS 12.0 or later. For custom targets, flavors, or manual migration, follow [Flutter's Swift Package Manager guide](https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers/).

Keep CocoaPods if other plugins still require it. Flutter can use both dependency managers in the same application.

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

Initialize **Error Monitoring** with `Sentry.init()` and run your application in its `appRunner` callback to capture uncaught exceptions and unhandled asynchronous errors. **Logs** and **Application Metrics** are enabled by default in SDK v10, and you'll learn how to send them in steps [#3](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#send-logs) and [#4](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#send-application-metrics-). This guide also enables **Tracing** and **Session Replay**.

Want to learn more about these features?

* [**Issues**](https://docs.sentry.io/product/issues.md) (always enabled): Automatically capture Flutter framework errors and unhandled asynchronous errors. Report handled errors with Sentry.captureException.
* [**Tracing**](https://docs.sentry.io/product/tracing.md): Track software performance while seeing the impact of errors across multiple systems. For example, distributed tracing allows you to follow a request from the frontend to the backend and back.
* [**Session Replay**](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay.md): View a video-like reproduction of your Flutter app on iOS and Android to see what happened before, during, and after a problem.
* [**Logs**](https://docs.sentry.io/product/logs.md): Centralize and analyze your application logs to correlate them with errors and performance issues. Search, filter, and visualize log data to understand what's happening in your applications.
* [**Application Metrics**](https://docs.sentry.io/product/metrics.md) (always enabled): Track and analyze custom application metrics, such as response times and database query durations, to understand trends and patterns in your application's performance and behavior over time.

### [Initialize the Sentry SDK](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#initialize-the-sentry-sdk)

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

Import and initialize the SDK in your app's entry point as shown in the code snippet below.

The snippet also turns on:

* Tracing: via [`tracesSampleRate`](https://docs.sentry.io/platforms/dart/guides/flutter/configuration/options.md#tracesSampleRate)
* Session Replay: sampled with [`replay.sessionSampleRate` and `replay.onErrorSampleRate`](https://docs.sentry.io/platforms/dart/guides/flutter/session-replay.md#sampling)
* Additional user and request data: via [`sendDefaultPii`](https://docs.sentry.io/platforms/dart/guides/flutter/configuration/options.md#sendDefaultPii)

To skip tracing, omit `tracesSampleRate`. To skip automatic Session Replay recording, omit both replay sample rates. To discard logs or metrics, return `null` from [`beforeSendLog`](https://docs.sentry.io/platforms/dart/guides/flutter/logs.md#beforesendlog) or [`beforeSendMetric`](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#beforesendmetric).

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

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = 'https://<key>@o<orgId>.ingest.sentry.io/<projectId>';

      /// Allows sending default personal data, such as IP addresses,
      // when available from the SDK's integrations.
      options.sendDefaultPii = true;

      // Enables Tracing.
      // Set to 1.0 to capture 100% of spans for tracing.
      // We recommend reducing this value in production.
      options.tracesSampleRate = 1.0;

      // Capture replays for 10% of all sessions,
      // plus for 100% of sessions with an error
      options.replay.onErrorSampleRate = 1.0;
      options.replay.sessionSampleRate = 0.1;
    },
    appRunner: () => runApp(
      SentryWidget(
        child: MyApp(),
      ),
    ),
  );

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

## [Send Logs](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#send-logs)

Call `Sentry.logger` from your application code after initialization to send structured logs at different levels. You can add attributes to make logs easier to search and filter.

See [Set Up Logs](https://docs.sentry.io/platforms/dart/guides/flutter/logs.md) for all available logging methods and message formatting.

```dart
Sentry.logger.info('Order completed', attributes: {
  'order_id': SentryAttribute.string('12345'),
  'total': SentryAttribute.double(99.99),
});

Sentry.logger.warn('Slow operation detected');
Sentry.logger.error('Validation failed');
```

If you use the Dart `logging` package, add the [`sentry_logging` integration](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/logging.md) to send its records to Sentry.

## [Send Application Metrics NEW](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#send-application-metrics-)

Call `Sentry.metrics` from your application code after initialization to send counters, gauges, and distributions. Add attributes to filter and group metrics in Sentry.

See [Set Up Metrics](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md) for metric types, attributes, and configuration options.

```dart
Sentry.metrics.count('checkout.failed', 1);
Sentry.metrics.gauge('queue.depth', 42);
Sentry.metrics.distribution('api_latency', 187, unit: 'millisecond');
```

## [Verify Your Setup](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#verify-your-setup)

Let's test your setup and confirm that data reaches your Sentry project.

Add this intentional error to your application:

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

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

Run your app to send the test error to Sentry:

```bash
flutter run
```

### [View Captured Data in Sentry](https://docs.sentry.io/platforms/dart/guides/flutter/manual-setup.md#view-captured-data-in-sentry)

Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear).

Need help locating captured data in your Sentry project?

* Open the [**Issues**](https://sentry.io/orgredirect/organizations/:orgslug/issues/) page and select an error from the issues list to view the full details and context of this error. For more details, see the [Issue Details documentation](https://docs.sentry.io/product/issues/issue-details.md).
* Open the [**Traces**](https://sentry.io/orgredirect/organizations/:orgslug/explore/traces/) page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click [here](https://docs.sentry.io/product/sentry-basics/getting-started-tutorial/generate-first-error.md#ui-walkthrough).
* Open the [**Replays**](https://sentry.io/orgredirect/organizations/:orgslug/replays/) page and select an entry from the list to get a detailed view where you can replay the interaction and get more information to help you troubleshoot.
* Open the [**Logs**](https://sentry.io/orgredirect/organizations/:orgslug/explore/logs/) page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click [here](https://docs.sentry.io/product/logs.md#overview).
* Open the [**Application Metrics**](https://sentry.io/orgredirect/organizations/:orgslug/explore/metrics) page to view and analyze your metrics. For more details, see this [interactive walkthrough](https://docs.sentry.io/product/metrics.md#overview).

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

At this point, you should have integrated Sentry into your Flutter application and should already be sending data to your Sentry project.

Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:

* Explore [practical guides](https://docs.sentry.io/get-started/guides.md) on what to monitor, log, track, and investigate after setup
* Add readable [stack traces](https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols.md#when-to-upload-debug-symbols) to errors
* Add [performance instrumentation to your app](https://docs.sentry.io/platforms/dart/guides/flutter/tracing/instrumentation.md)

Are you having problems setting up the SDK?

* Find various topics in [Troubleshooting](https://docs.sentry.io/platforms/dart/guides/flutter/troubleshooting.md)
* [Get support](https://www.sentry.help/en/)
