sentry 2.3.1

  • Readme
  • Changelog
  • Installing
  • 91 client for Dart #

Build Status

Use this library in your Dart programs (Flutter, command-line and (TBD) AngularDart) to report errors thrown by your program to error tracking service.

Versions #

>=0.0.0 <2.0.0 is the range of versions compatible with Dart 1.

>=2.0.0 <3.0.0 is the range of versions compatible with Dart 2.

Usage #

Sign up for a account and get a DSN at

Add sentry dependency to your pubspec.yaml:

  sentry: any

In your Dart code, import package:sentry/sentry.dart and create a SentryClient using the DSN issued by

import 'package:sentry/sentry.dart';

final SentryClient sentry = new SentryClient(dsn: YOUR_DSN);

In an exception handler, call captureException():

main() async {
  try {
  } catch(error, stackTrace) {
    await sentry.captureException(
      exception: error,
      stackTrace: stackTrace,

Tips for catching errors #

  • Use a try/catch block, like in the example above.

  • Create a Zone with an error handler, e.g. using runZoned.

    var sentry = SentryClient(dsn: "https://...");
    // Run the whole app in a zone to capture all uncaught errors.
      () => runApp(MyApp()),
      onError: (Object error, StackTrace stackTrace) {
        try {
            exception: error,
            stackTrace: stackTrace,
          print('Error sent to $error');
        } catch (e) {
          print('Sending report to failed: $e');
          print('Original error: $error');
  • For Flutter-specific errors (such as layout failures), use FlutterError.onError. For example:

    var sentry = SentryClient(dsn: "https://...");
    FlutterError.onError = (details, {bool forceReport = false}) {
      try {
          exception: details.exception,
          stackTrace: details.stack,
      } catch (e) {
        print('Sending report to failed: $e');
      } finally {
        // Also use Flutter's pretty error logging to the device's console.
        FlutterError.dumpErrorToConsole(details, forceReport: forceReport);
  • Use Isolate.current.addErrorListener to capture uncaught errors in the root zone.

Found a bug? #

Please file it at

package:sentry changelog #

2.3.1 #

  • Support non-standard port numbers and paths in DSN URL.

2.3.0 #

2.2.0 #

  • Add a stackFrameFilter argument to SentryClient's capture method (96be842).
  • Clean-up code using pre-Dart 2 API (91c7706, b01ebf8).

2.1.1 #

2.1.0 #

  • Support DNS format without secret key.
  • Remove dependency on package:quiver.
  • The clock argument to SentryClient constructor should now be ClockProvider (but still accepts Clock for backwards compatibility).

2.0.2 #

  • Add support for user context in Sentry events.

2.0.1 #

  • Invert stack frames to be compatible with Sentry's default culprit detection.

2.0.0 #

  • Fixed deprecation warnings for Dart 2
  • Refactored tests to work with Dart 2

1.0.0 #

  • first and last Dart 1-compatible release (we may fix bugs on a separate branch if there's demand)
  • fix code for Dart 2

0.0.6 #

  • use UTC in the timestamp field

0.0.5 #

  • remove sub-seconds from the timestamp

0.0.4 #

  • parse and report async gaps in stack traces

0.0.3 #

  • environment attributes
  • auto-generate event_id and timestamp for events

0.0.2 #

  • parse and report stack traces
  • use x-sentry-error HTTP response header
  • gzip outgoing payloads by default

0.0.1 #

  • basic ability to send exception reports to

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  sentry: ^2.3.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sentry/sentry.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, other

Primary library: package:sentry/sentry.dart with components: io.

Health suggestions

Fix lib/sentry.dart. (-2.48 points)

Analysis of lib/sentry.dart reported 5 hints:

line 80 col 9: DO use curly braces for all flow control structures.

line 205 col 7: DO use curly braces for all flow control structures.

line 227 col 9: DO use curly braces for all flow control structures.

line 460 col 7: DO use curly braces for all flow control structures.

line 463 col 7: DO use curly braces for all flow control structures.

Fix lib/src/stack_trace.dart. (-1 points)

Analysis of lib/src/stack_trace.dart reported 2 hints:

line 52 col 5: DO use curly braces for all flow control structures.

line 67 col 5: DO use curly braces for all flow control structures.

Fix lib/src/utils.dart. (-0.50 points)

Analysis of lib/src/utils.dart reported 1 hint:

line 33 col 5: DO use curly braces for all flow control structures.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and sentry.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http >=0.11.0 <2.0.0 0.12.0+2
meta >=1.0.0 <2.0.0 1.1.8
stack_trace >=1.0.0 <2.0.0 1.9.3
usage >=3.0.0 <4.0.0 3.4.1
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
args >=0.13.0 <2.0.0
mockito >=2.0.0 <4.0.0
test >=0.12.0 <2.0.0
yaml >=2.1.0 <3.0.0