Dart

Get the SDK from pub.dev by adding the following to your pubspec.yaml:

pubspec.yaml
Copied
dependencies:
  sentry: ^5.0.0

Import Sentry and initialize it:

Copied
import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init((options) => options.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0');
}

Capture a test exception:

Copied
import 'package:sentry/sentry.dart';

try {
  aMethodThatMightFail();
} catch (exception, stackTrace) {
  await Sentry.captureException(
    exception,
    stackTrace: stackTrace,
  );
}

Source code

The Sentry Dart/Flutter SDK can be found on GitHub sentry-dart.

You can edit this page on GitHub.