recordError method

  1. @override
Future<void> recordError(
  1. Object error,
  2. StackTrace? stackTrace, {
  3. String? reason,
  4. Map<String, dynamic>? context,
  5. bool fatal = false,
})
override

Records error with optional stackTrace and contextual reason.

Set fatal to true for crashes that terminated the app.

Implementation

@override
Future<void> recordError(
  Object error,
  StackTrace? stackTrace, {
  String? reason,
  Map<String, dynamic>? context,
  bool fatal = false,
}) async {
  if (!_enabled) {
    return;
  }
  if (context != null) {
    for (final entry in context.entries) {
      await _crashlytics.setCustomKey(entry.key, entry.value.toString());
    }
  }
  await _crashlytics.recordError(
    error,
    stackTrace,
    reason: reason,
    fatal: fatal,
  );
}