| package | build | pub | likes | popularity | pub points |
|---|---|---|---|---|---|
| sentry | |||||
| sentry-flutter |
All you need is the Dart SDK. The sentry package doesn't depend on the Flutter SDK.
The SDK currently supports Android, iOS and Web. We build the example app for these targets in 3 platforms: Windows, macOS and Linux. This is to make sure you'd be able to contribute to this project if you're using any of these operating systems.
We also run CI against the Flutter stable and beta channels so you should be able to build it if you're in one of those.
- The Dart SDK (if you want to change
sentry-dart) - The Flutter SDK (if you want to change
sentry-dartorsentry-flutter) - Android: Android SDK with NDK: The example project includes C++.
- iOS: You'll need a Mac with xcode installed.
- Web: No additional dependencies.
Versions 3.0.1 and higher support [Flutter][flutter] (mobile, web, desktop),
command-line/server Dart VM, and [AngularDart][angular_sentry].
Versions below 3.0.1 are deprecated.
Sign up for a Sentry.io account and get a DSN at http://sentry.io.
Add sentry dependency to your pubspec.yaml:
dependencies:
sentry: ^4.0.0In your Dart code, import package:sentry/sentry.dart and Sentry.init(...) using the DSN issued by Sentry.io:
import 'package:sentry/sentry.dart';
Sentry.init((options) => options.dsn = '___PUBLIC_DSN___');In an exception handler, call captureException():
try {
aMethodThatMightFail();
} catch (exception, stackTrace) {
Sentry.captureException(exception, stackTrace: stackTrace);
}- Use a
try/catchblock, like in the example above. - Create a
Zonewith an error handler, e.g. using [runZonedGuarded][run_zoned_guarded].
import 'dart:async';
import 'package:sentry/sentry.dart';
// Wrap your 'runApp(MyApp())' as follows:
void main() async {
runZonedGuarded(
() => runApp(MyApp()),
(error, stackTrace) {
Sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
},
);
}- For Flutter-specific errors (such as layout failures), use [FlutterError.onError][flutter_error]. For example:
import 'package:flutter/foundation.dart';
import 'package:sentry/sentry.dart';
FlutterError.onError = (details, {bool forceReport = false}) {
Sentry.captureException(
exception: details.exception,
stackTrace: details.stack,
);
};- Use
Isolate.current.addErrorListenerto capture uncaught errors in the root zone.