This repo has been deprecated in favor of the official Bugsnag Flutter SDK (same package name). Please see the announcement or skip ahead to the new, official repo.
Unofficial native bindings to the Bugsnag SDK. Android is still experimental.
void main() async {
await Bugsnag.instance.configure(iosApiKey: 'YOUR_API_KEY', androidApiKey: 'YOUR_API_KEY', releaseStage: 'production');
// Capture Flutter errors automatically:
FlutterError.onError = Bugsnag.instance.recordFlutterError;
runZonedGuarded(() {
runApp(MyApp());
}, (error, stackTrace) {
Bugsnag.instance.recordError(error, stackTrace);
});
}
To better debug a crash, breadcrumbs can be transmitted to Bugsnag. Some are captured by default, but Flutter interactions are not. To track screens, use the built-in observer:
import 'package:bugsnag_flutter/bugsnag_observer.dart';
MaterialApp(
// ...your material config...
home: HomeScreen(),
navigatorObservers: [
BugsnagObserver(),
],
);
Or log specific events:
FlatButton(
onTap: () {
Bugsnag.instance.leaveBreadcrumb('Button Tapped', type: BugsnagBreadcrumb.user);
}
);