Sentry for Flutter

Learn how to set up Sentry in your Flutter app, capture your first errors and traces, and view them in Sentry.

Agent-Assisted Setup
Use curl to download, read and follow https://skills.sentry.dev/instrument to set up the Sentry Flutter SDK.
Your agent will set up Sentry in your Flutter app automatically. Works with Cursor, Claude Code, Codex, and more.View docs ↗
Install the full plugin

Install the Sentry plugin to give your assistant every skill. See the installation docs for more details.

Copied
npx @sentry/agent-plugin install

These instructions use Sentry Flutter SDK v10. You need:

  • A Sentry account and project
  • A Flutter application using Flutter 3.44.0 and Dart 3.12.0 or later
  • Android API 26 or later for Android apps. Set your app's minSdk to 26 or higher.
  • 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 before upgrading to v10.

Sentry captures data by using an SDK within your application's runtime.

We recommend installing the SDK through our Sentry Wizard. Run one of the following commands inside your project directory:

Copied
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.

The following tasks will be performed by the Sentry Wizard
  • Update your pubspec.yaml with the sentry_flutter and sentry_dart_plugin packages.
  • Create a sentry.properties file (gitignored) with a Sentry CLI auth token.
  • Prompt you for optional features and patch main.dart with SentryFlutter.init.
  • Add a sample exception that is captured when the app starts so you can verify the setup.

The wizard will prompt you to enable optional features. Select the same options here so this guide can show you how to verify them:

Want to learn more about these features?
  • Issues (always enabled): Sentry's core error monitoring product that automatically reports errors, uncaught exceptions, and crashes. If you have something that looks like an exception, Sentry can capture it.
  • Tracing: 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: Get to the root cause of an issue faster by viewing a video-like reproduction of what users saw in your app before, during, and after the problem.
  • Logs: 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 (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.

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

The wizard added a sample exception to main.dart that is captured when the app starts. Run your app to send it to Sentry:

Copied
flutter run

After you've confirmed the issue in Sentry, remove the sample exception from main.dart so it isn't captured on every launch.

To test your tracing configuration, create a custom transaction and span:

Copied
final transaction = Sentry.startTransaction('test-transaction', 'task');
final span = transaction.startChild('test-span');
await span.finish();
await transaction.finish();

Logs are enabled by default. Use the Sentry logger to send structured logs from anywhere in your application:

Copied
Sentry.logger.info('User clicked checkout button');

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

Sentry.logger.warn('Warning message');
Sentry.logger.error('Error occurred');

Metrics are enabled by default. Send test metrics from your app to verify that metrics are arriving in Sentry:

Copied
Sentry.metrics.count('checkout.failed', 1);
Sentry.metrics.gauge('queue.depth', 42);
Sentry.metrics.distribution('cart.amount_usd', 187.5);

Now, head over to your project on 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 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.
  • Open the 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.
  • Open the 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 page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click here.
  • Open the Application Metrics page to view and analyze your metrics. For more details, see this interactive walkthrough.

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:

Are you having problems setting up the SDK?
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").