Sentry Dart Plugin

Learn how to use the Sentry Dart Plugin to automatically upload debug symbols for your Flutter application.

The Sentry Dart Plugin is the recommended way to upload debug symbols for Flutter applications. It uploads debug symbols and source maps to Sentry, this enables:

  • Symbolicated stacktraces - See actual function names instead of obfuscated code
  • Source context - Stacktraces enhanced with source code around the location of stack frames that caused the error
  • Symbolicated issue titles

For a detailed list of features see the Features section.

In your pubspec.yaml, add sentry_dart_plugin as a new dev dependency:

pubspec.yaml
Copied
dev_dependencies:
  sentry_dart_plugin: ^3.2.1

The Sentry Dart Plugin requires basic configuration in your pubspec.yaml file:

pubspec.yaml
Copied
sentry:
  project: ___PROJECT_SLUG___
  org: ___ORG_SLUG___
  auth_token: ___ORG_AUTH_TOKEN___
  # Absolute or relative path to the Dart symbol map file
  # Used to make obfuscated Flutter issue titles readable on iOS and Android
  # See the "Building Your Application" section below for more details on how to generate the symbol map file
  # Available since version 3.2.0 of the Sentry Dart Plugin
  # Only applicable for obfuscated builds
  dart_symbol_map_path: build/app/obfuscation.map.json
  # ___PRODUCT_OPTION_START___ source-context
  # Enable source context
  upload_sources: true
  # ___PRODUCT_OPTION_END___ source-context
  # ___PRODUCT_OPTION_START___ source-maps
  # Enable source maps (only relevant for Flutter Web)
  upload_source_maps: true
  # ___PRODUCT_OPTION_END___ source-maps

You can also set configuration values with environment variables or --sentry-define.

Environment variables:

Copied
export SENTRY_RELEASE=my-app@1.0.0

Command-line arguments (--sentry-define):

Copied
dart run sentry_dart_plugin --sentry-define=release=my-app@1.0.0

When the same value is set in multiple places, the highest priority wins in this order (highest to lowest):

  • Environment variables
  • --sentry-define command-line arguments
  • pubspec.yaml
  • sentry.properties

For the full list of configuration options, see the Configuration Reference section.

Before running the plugin, build your Flutter application. Obfuscation is encouraged for production builds, and will make uploading debug symbols necessary to get readable stack traces.

Copied
# Replace <target> with the mobile or desktop target you're building for: https://docs.flutter.dev/deployment/obfuscate#supported-targets
flutter build <target> --obfuscate --split-debug-info=<output-directory> --extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json

After building your application, run the plugin to upload debug symbols:

Copied
flutter pub run sentry_dart_plugin

Uploading ProGuard mapping files is recommended in order to see symbolicated stack traces for errors that occur in the native Android layer:

  • Use the Sentry Android Gradle Plugin (Recommended).

    After installing the Sentry Android Gradle Plugin, set autoInstallation to false in your app/build.gradle file:

    app/build.gradle
    Copied
    sentry {
        autoInstallation {
          enabled = false
        }
    }
    

    This avoids conflicts because Sentry Flutter already ships with a compatible Sentry Android SDK.

    Follow the Android Gradle Plugin guide to complete the ProGuard mapping setup.

  • Use the Sentry CLI.

    Alternatively, you can use the Sentry CLI to manually upload mapping files.

The following table lists all available configuration options for the Sentry Dart Plugin.

The Key column refers to the option name used in:

  • pubspec.yaml
  • sentry.properties
  • --sentry-define

When available, environment variable names are listed in the Environment Variable column.

KeyEnvironment VariableTypeDefaultDescription
projectSENTRY_PROJECTstring(Required) Your project's name (e.g., sentry-flutter)
orgSENTRY_ORGstring(Required) Your organization's slug (e.g., sentry-sdks)
auth_tokenSENTRY_AUTH_TOKENstring(Required) The Sentry auth token
upload_debug_symbolsbooleantrueEnables or disables automatic upload of debug symbols
upload_source_mapsbooleanfalseEnables or disables automatic upload of source maps (Flutter Web)
upload_sourcesbooleanfalseEnables or disables source code upload
dart_symbol_map_pathstringPath to the Dart symbol map file for readable obfuscated issue titles
releaseSENTRY_RELEASEstringname@version from pubspecThe release version for source maps
distSENTRY_DISTstringBuild number (after + in version)Custom distribution identifier
build_pathstringbuildBase build directory
web_build_pathstringwebThe web build folder path relative to build_path
symbols_pathstring.The directory containing debug symbols. This recursively searches for debug files.
urlSENTRY_URLstringThe URL of your Sentry instance (for self-hosted)
url_prefixstringURL prefix for JS source maps (e.g., ~/). Required for non-root web deployments
legacy_web_symbolicationbooleanfalseUses legacy symbolication for Flutter Web. See Debug IDs
commitsstringautoRelease commits integration
ignore_missingbooleanfalseIgnore missing commits previously used in the release
wait_for_processingbooleanfalseWhether to wait for server-side processing of uploaded files
log_levelSENTRY_LOG_LEVELstringwarnLog level for sentry-cli: trace, debug, info, warn, error
bin_dirstring.dart_tool/pub/bin/sentry_dart_pluginFolder where the plugin downloads the sentry-cli binary
bin_pathstringPath to a sentry-cli binary to use instead of downloading
sentry_cli_cdn_urlSENTRYCLI_CDNURLstringhttps://downloads.sentry-cdn.com/sentry-cliAlternative place to download sentry-cli
sentry_cli_versionstringOverride the sentry-cli version to download

The Sentry Dart Plugin uploads debug symbols and source maps to make your Flutter errors readable. Here's what you get on each platform:

FeatureiOSAndroidmacOSWindowsLinux
Symbolicated Stacktrace
Source Context✓*✓*✓*✓*✓*
Symbolicated Issue Title

FeatureiOSAndroidmacOSWindowsLinux
Symbolicated Stacktrace
Source Context✓*✓*✓*✓*✓*
Symbolicated Issue TitleNot SupportedNot SupportedNot Supported

*Requires --split-debug-info build flag supplied to the flutter build command

FeatureSupport
Symbolicated Stacktrace
Source Context
Symbolicated Issue TitleNot Supported

Why does the plugin say a release is missing?

The plugin fails because a previous release cannot be found in the git history.

Set ignore_missing: true in your configuration to bypass this validation:

pubspec.yaml
Copied
sentry:
  ignore_missing: true
Why aren't Flutter Web source maps working with older SDKs?

Source maps aren't working for Flutter Web with plugin version 3.0.0+.

Upgrade your Sentry Flutter SDK to 9.1.0+.

If you're using a version of the Sentry Flutter SDK earlier than 9.1.0, you can set legacy_web_symbolication: true to use the legacy symbolication method.

Why don't my Flutter Web source maps match when using a URL prefix?

Source maps aren't matching for a Flutter Web app that's not deployed at the root URL (e.g., https://example.com/my-app/ instead of https://example.com/).

Configure both the url_prefix in the plugin and update your stack frame paths in the SDK to match.

Step 1: Add the url_prefix to your plugin configuration:

pubspec.yaml
Copied
sentry:
  upload_source_maps: true
  url_prefix: ~/my-app/

Step 2: Update the stack frame paths using beforeSend so they include the same prefix. This allows Sentry to match the source maps correctly:

Copied
options.beforeSend = (event, hint) {
  for (final exception in event.exceptions ?? <SentryException>[]) {
    final stackTrace = exception.stackTrace;
    if (stackTrace != null) {
      for (final frame in stackTrace.frames) {
        // Replace with your actual domain and path prefix
        const baseUrl = 'https://example.com/';
        final modifiedAbsPath = frame.absPath?.replaceFirst(
          baseUrl,
          '${baseUrl}my-app/',
        );
        frame.absPath = modifiedAbsPath;
      }
    }
  }
  return event;
};
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").