Created
December 12, 2018 13:25
-
-
Save florent37/58ca81f1666be6767657c659d655eea4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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