Skip to content

A Flutter plugin to use the Bugsnag Crashlytics Service.

License

Notifications You must be signed in to change notification settings

Moujarkash/bugsnag-crashlytics

Repository files navigation

bugsnag_crashlytics plugin

A Flutter plugin to use the Bugsnag Crashlytics Service.

Usage

Use the plugin

Add the following imports to your Dart code:

import 'package:bugsnag_crashlytics/bugsnag_crashlytics.dart';

Setup Crashlytics:

void main() {
  
  // pass your key api of bugsnag to the plugin to setup
  BugsnagCrashlytics.instance.register(androidApiKey: "ANDROID_API_KEY", iosApiKey: "IOS_API_KEY", releaseStage: 'RELEASE_STAGE', appVersion: 'APP_VERSION');
  
  // Pass all uncaught errors from the framework to Crashlytics.
  FlutterError.onError = BugsnagCrashlytics.instance.recordFlutterError;
  
  runApp(MyApp());
}

Overriding FlutterError.onError with BugsnagCrashlytics.instance.recordFlutterError will automatically catch all errors that are thrown from within the Flutter framework.
If you want to catch errors that occur in runZoned, you can supply BugsnagCrashlytics.instance.recordError to the onError parameter:

runZoned<Future<void>>(() async {
    // ...
  }, onError: BugsnagCrashlytics.instance.recordError);

Result

If an error is caught, you should see the following messages in your logs:

flutter: Flutter error caught by Crashlytics plugin:
// OR if you use recordError for runZoned:
flutter: Error caught by Crashlytics plugin <recordError>:
// Exception, context, information, and stack trace in debug mode
// OR if not in debug mode:
flutter: Error reported to Crashlytics.

Note: It may take awhile (up to 24 hours) before you will be able to see the logs appear in your Bugsnag console.

About

A Flutter plugin to use the Bugsnag Crashlytics Service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •