crashops_flutter 0.0.82 copy "crashops_flutter: ^0.0.82" to clipboard
crashops_flutter: ^0.0.82 copied to clipboard

outdated

This Flutter plugin will bridge your Flutter app with CrashOps SDK, for iOS and Android. CrashOps helps you to easily monitor crash and error reports. It's super easy to use and work with plug n' play [...]

CrashOps plugin for Flutter #

License: MIT

This Flutter plugin helps to bridge your app with the CrashOps native SDK. CrashOps SDK helps you monitor your app's crashes and Flutter errors.

Installation #

Easiest to install, it's a "plug n' play" plugin. All you need to do is add crashops_flutter dependency and the SDK will automatically start monitoring on each application launch.

Required changes in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
...
  crashops_flutter: any
...

Usage #

(see the a full example project in: github.com/CrashOps/Flutter-Example)

Catch errors #

To catch errors from your Flutter app, edit your main() method as follows:

void main() {
  // Catching errors in Flutter actually depends on the Flutter developer's code.
  CrashOps crashOps = CrashOps();

  var onErrorPreviousCallback = FlutterError.onError;

  // Catches only Flutter errors
  FlutterError.onError = (FlutterErrorDetails details) {
    crashOps.onError(details);
    FlutterError.dumpErrorToConsole(details, forceReport: false);
    if (onErrorPreviousCallback != null && FlutterError.dumpErrorToConsole != onErrorPreviousCallback) {
      onErrorPreviousCallback(details);
    }
  };

  // Catches all Dart
  runZoned(() {
    runApp(MyApp());
  }, onError: (error, stackTrace) {
    // This catches also Dart errors, not only Flutter errors.
    // For more details, read: https://flutter.dev/docs/cookbook/maintenance/error-reporting
    crashOps.onError(error, stackTrace);

    if (error is FlutterErrorDetails) {
      FlutterErrorDetails details = error;

      FlutterError.dumpErrorToConsole(details, forceReport: false);
      if (onErrorPreviousCallback != null && FlutterError.dumpErrorToConsole != onErrorPreviousCallback) {
        onErrorPreviousCallback(details);
      }
    }
  });
}

Custom configurations #

class _MyAppState extends State<MyApp> {
  // It's not mandatory to put those configurations inside a State.
  // It may also be in the "main()" function.
  final CrashOps crashOps = CrashOps();

  ...

  @override
  void initState() {
    super.initState();

    // If you're willing to create logs in debug
    crashOps.isEnabledInDebugMode = true;
    // If you wish to upload logs to CrashOps servers
    crashOps.setClientId(
        "the-client-id-you-received-from-crashops-customer-support");
    // If you wish to add more details in each log
    crashOps.setMetadata({"yo": "that's my awesome app!"});
  }

  ...

}

Don't have Flutter yet? #

For help getting started with Flutter, view their online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Acknowledgments #

iOS: KSCrash library.

Android: retrofit.

Flutter: https://pub.dev/flutter

TODO #

Become production ready :)

Our SDK is still under development, stay tuned: CrashOps.com

3
likes
0
pub points
0%
popularity

Publisher

unverified uploader

This Flutter plugin will bridge your Flutter app with CrashOps SDK, for iOS and Android. CrashOps helps you to easily monitor crash and error reports. It's super easy to use and work with plug n' play, just add it to your "dependencies" section and set a Client ID.

Homepage

License

unknown (LICENSE)

Dependencies

flutter, stack_trace

More

Packages that depend on crashops_flutter