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 SentryNavigationObserver to your MaterialApp, WidgetsApp or CupertinoApp

Copied
import 'package:flutter/widgets.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

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 (such as layout failures), 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.
You can edit this page on GitHub.