Dart

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

pubspec.yaml
Copied
dependencies:
  sentry: ^8.6.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.