setUpErrorHandlingWithAppMetrica function

void setUpErrorHandlingWithAppMetrica(
  1. AppMetricaConfig config
)

Implementation

void setUpErrorHandlingWithAppMetrica(AppMetricaConfig config) {
  if (config.flutterCrashReporting == false) {
    return;
  }
  if (_crashHandlingActivated) {
    return;
  }
  _crashHandlingActivated = true;
  final prev = FlutterError.onError;
  FlutterError.onError = (FlutterErrorDetails details) async {
    AppMetrica._logger.warning("error caught by handler ${details.summary}", details.exception, details.stack);
    await AppMetrica._appMetrica.reportUnhandledException(convertErrorDetails(
        details.exception.runtimeType.toString(),
        details.summary.toString(),
        details.stack));
    if (prev != null) {
      prev(details);
    }
  };
}