logError function
- Object error,
- StackTrace? stack,
- 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(),
},
);
}