Advanced Usage

Requirements

For the usage of the Flutter SDK, the minimal required Dart SDK version is 2.8.0 and Flutter SDK version is 1.17.0

Automatic Breadcrumbs

The Flutter SDK already captures breadcrumbs automatically via the Native SDKs.

If you wish to add additional Navigation breadcrumbs for Flutter Apps, Add the SentryNavigatorObserver to your MaterialApp, WidgetsApp or CupertinoApp

Copied
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

MaterialApp(
  navigatorObservers: [
    SentryNavigatorObserver(),
  ],
  // other parameters
)

To track automatic Breadcrumbs for HTTP requests, Check out the SentryHttpClient Wrapper for the http library.

Uploading Debug Symbols (Android and iOS)

Known Limitations

  • Flutter split-debug-info and obfuscate flags aren't yet supported on iOS; they are supported only on Android. If this feature is enabled, Dart stack traces are not human readable, this is a tooling limitation, See: 43612 and 43274.
  • If you enable the split-debug-info feature, you must upload the Debug Symbols manually.
  • Also, Issue's titles might be obfuscated as we rely on the runtimeType, but they may not be human-readable, See: Obfuscate Caveat
  • Layout related errors are only caught by FlutterError.onError in debug mode. In release mode, they are removed by the Flutter framework. See Flutter build modes.

Tips for Catching Errors

  • Use a try/catch block
  • Use a catchError block for Futures
  • The SDK already runs your init callback on an error handler, e.g. using runZonedGuarded, are captured automatically
  • Flutter-specific errors, e.g. using FlutterError.onError, are captured automatically
  • Isolate errors on the current Isolate which is the equivalent of a main/UI thread, e.g. using Isolate.current.addErrorListener, are captured automatically (Only for non-Web Apps).
  • For your own Isolates, add an ErrorListener and call Sentry.captureException

Caveat

Always prefer the SentryFlutter.init(...) instead of Sentry.init(...) as it adds the Flutter integrations on top of the Dart SDK.

Advanced Usage (Android and iOS)

Dart environment variables

  • You can configure the SENTRY_DSN, SENTRY_RELEASE, SENTRY_DIST and SENTRY_ENVIRONMENT via the Dart environment variables passing the --dart-define flag to the compiler.

Building specific ABI on Android

The Sentry Flutter SDK includes the Sentry Android SDK, which bundles multiple native libraries for multiple ABIs. Building a Flutter app for a specific ABI using the --target-platform argument, for example an ARM 32bit apk, looks like this, which should also include the --split-per-abi flag:

Copied
flutter build apk --target-platform=android-arm --split-per-abi
You can edit this page on GitHub.