sendException method

Future<void> sendException(
  1. dynamic exception,
  2. StackTrace? stack, {
  3. dynamic reason,
  4. bool? isCrashPrint,
  5. bool isFatal = true,
})

Implementation

Future<void> sendException(dynamic exception, StackTrace? stack,
    {dynamic reason,
      bool? isCrashPrint,
      bool isFatal = true}) async {

  // Checking print
  isCrashPrint ??= kDebugMode;


  if (isCrashPrint) {
    // Print Stack Trace
    print('Exception: $exception');

    if(stack != null) print("\n$stack");

  }

  final StackTrace stacktrace = (stack.toString().isEmpty || stack == null)
      ? StackTrace.current
      : stack;
  // To find build Architecture

  final pattern = RegExp(r'arch:\s*([\w\d]+)');
  final match = pattern.firstMatch(stack.toString());
  final arch = kReleaseMode ? match?.group(1) : null;

  return AppticsFlutterPlatform.instance.crashTracker(exception: exception.toString(), stacktrace: stacktrace.toString(), reason: reason.toString(), arch: arch, isFatal: isFatal);
}