launchEmailLog static method

Future<bool> launchEmailLog(
  1. String appTitle,
  2. String email,
  3. String body
)

Implementation

static Future<bool> launchEmailLog(String appTitle, String email, String body) async {
  final zipPath = await getLogPath('log.zip');
  final logFolder = await getLogPath();
  final files = Directory(logFolder) //
      .listSync(followLinks: false)
      .whereType<File>()
      .where((log) => p.extension(log.path) != '.zip')
      .map((log) => log)
      .toList();

  final zip = File(zipPath);
  if (zip.existsSync()) zip.deleteSync();
  await ZipFile.createFromFiles(
    sourceDir: Directory(logFolder),
    files: files,
    zipFile: zip,
  );

  return await _sendMail(
    body: body,
    subject: 'Log ($appTitle)',
    recipients: [email],
    attachmentPaths: [zipPath],
    isHTML: false,
  );
}