logError function

void logError(
  1. Object error,
  2. StackTrace? stack,
  3. String? library
)

Log an error to file and send to webhook if analytics are enabled

Implementation

void logError(Object error, StackTrace? stack, String? library) {
  // Print to console
  if (kDebugMode) {
    print('$error at $stack in $library');
    return;
  }
  // Log to file
  logInfo('$error at $stack in $library');
  // Send to webhook if analytics are enabled
  if (!plausible.enabled) return;
  Dio().post(
    errorUrl,
    data: {
      'error': error.toString(),
      'stack': stack.toString(),
      'library': library.toString(),
    },
  );
}