Skip to content

Instantly share code, notes, and snippets.

@florent37
Created December 12, 2018 13:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florent37/58ca81f1666be6767657c659d655eea4 to your computer and use it in GitHub Desktop.
Save florent37/58ca81f1666be6767657c659d655eea4 to your computer and use it in GitHub Desktop.
void main() async {
bool isInDebugMode = false;
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
// In development mode simply print to console.
FlutterError.dumpErrorToConsole(details);
} else {
// In production mode report to the application zone to report to
// Crashlytics.
Zone.current.handleUncaughtError(details.exception, details.stack);
}
};
await FlutterCrashlytics().initialize();
runZoned<Future<Null>>(() async {
runApp(MyApp());
}, onError: (error, stackTrace) async {
// Whenever an error occurs, call the `reportCrash` function. This will send
// Dart errors to our dev console or Crashlytics depending on the environment.
await FlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment