Sentry for Flutter
Learn how to set up Sentry in your Flutter app, capture your first events, and view them in Sentry.
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
minSdkto26or 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:
brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutter
brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutter
$downloadUrl = "https://github.com/getsentry/sentry-wizard/releases/download/v9.1.0/sentry-wizard-win-x64.exe"
Invoke-WebRequest $downloadUrl -OutFile sentry-wizard.exe
./sentry-wizard.exe -i flutter
downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v9.1.0/sentry-wizard-darwin-x64"
curl -L $downloadUrl -o sentry-wizard
chmod +x sentry-wizard
./sentry-wizard -i flutter
downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v9.1.0/sentry-wizard-darwin-arm64"
curl -L $downloadUrl -o sentry-wizard
chmod +x sentry-wizard
./sentry-wizard -i flutter
downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v9.1.0/sentry-wizard-linux-x64"
curl -L $downloadUrl -o sentry-wizard
chmod +x sentry-wizard
./sentry-wizard -i flutter
downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v9.1.0/sentry-wizard-linux-arm64"
curl -L $downloadUrl -o sentry-wizard
chmod +x sentry-wizard
./sentry-wizard -i flutter
npx @sentry/wizard@latest -i flutter
This will patch your project and configure the SDK. Logs and Application Metrics are enabled by default in SDK v10, and you'll learn how to send them in steps #2 and #3. 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.
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 for all available logging methods and message formatting.
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');
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 to send its records to Sentry.
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 for metric types, attributes, and configuration options.
Sentry.metrics.count('checkout.failed', 1);
Sentry.metrics.gauge('queue.depth', 42);
Sentry.metrics.distribution('api_latency', 187, unit: 'millisecond');
Sentry.metrics.count('checkout.failed', 1);
Sentry.metrics.gauge('queue.depth', 42);
Sentry.metrics.distribution('api_latency', 187, unit: 'millisecond');
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:
flutter run
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.
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).
At this point, you should have integrated Sentry into your Flutter application. Here's what to explore next:
- Explore practical guides on what to monitor, log, track, and investigate after setup
- Upload debug symbols and source maps for readable production stack traces. The wizard configures
sentry_dart_plugin; rundart run sentry_dart_pluginafter each production build to upload the files. In CI, provideSENTRY_AUTH_TOKENto the upload step. - Learn about Session Replay and its privacy controls
- Add performance instrumentation to your app
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").