How to setup sentry.io on flutter

flutter sentry.io
flutter pub add sentry_flutter
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
runZonedGuarded(() async {
await SentryFlutter.init(
(options) {
options.dsn = 'https://example@sentry.io/add-your-dsn-here';
},
);

runApp(MyApp());
}, (exception, stackTrace) async {
await Sentry.captureException(exception, stackTrace: stackTrace);
});
}
sentry.io dashboard
void onItemTapped(int idx) async {
setState(() => _selectedIdx = idx);
throw Exception('throw first error');
}
sentry.io dashboard
sentry.io debug mode
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
Future<void> main() async {
runZonedGuarded(() async {
await SentryFlutter.init(
(options) {
options.dsn = 'https://example@sentry.io/add-your-dsn-here';
option.debug = kDebugMode
},
);

runApp(MyApp());
}, (exception, stackTrace) async {
await Sentry.captureException(exception, stackTrace: stackTrace);
});
}

--

--

Entrepreneurship, React, Flutter, Firebase, Typescript, Javascript, NodeJS, ChatGPT, Crypto, Blockchain. Visit www.gamevsus.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Phong Yew Tong

Entrepreneurship, React, Flutter, Firebase, Typescript, Javascript, NodeJS, ChatGPT, Crypto, Blockchain. Visit www.gamevsus.com