uploadLog function

void uploadLog()

Manually trigger upload of log file

Implementation

void uploadLog() async {
  var file = File(getLogFilePath());
  if (!await file.exists()) return;

  // Date only
  var date = DateTime.now().toIso8601String().split('T')[0];

  // Generate ID based on hostname, date and OS
  var name = 'Logfile from $date on '
      '${Platform.operatingSystem} with ${Platform.operatingSystemVersion}';

  Dio().post(
    errorUrl,
    data: {
      'error': name,
      'stack': await file.readAsString(),
    },
  );
}