composeReportBugMail method
Export FLog and open default email client
messagae: Incase you want to take any input from user about error
Implementation
composeReportBugMail(String message) async {
try {
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
DeviceInfo().getInfo().then((value) async {
// FLog.info(text: 'Device info : $value');
Map<String, dynamic> deviceInfo = value!;
String body =
'AppVersion : ${packageInfo.version}\n Device OS : ${deviceInfo['systemName']}\n Device Model : ${deviceInfo['model']}\n Device OS Version : ${deviceInfo['systemVersion']}\n User Description: \n $message';
FLog.info(text: 'PackageInfo: $body');
_platform = deviceInfo['systemName'];
String appName = packageInfo.appName;
await FLog.exportLogs(); //.then((_) {
Future.delayed(const Duration(seconds: 1), (() {
getApplicationDocumentsDir().then((value) async {
Directory dataDir = Directory('$value/FLogs');
var now = DateTime.now();
var df = DateFormat('yyyy-MM-ddTHH:mm:ss');
String dateTime = df.format(now);
String zippath =
'$value/${appName}_${_userName!.trim()}_Logs_$dateTime.zip';
zippath = zippath.trim();
final zipFile = File(zippath);
// FLog.info(text: 'Zip path : $zipFile');
Directory destDir = Directory(zippath);
// FLog.info(text: 'directory : $dataDir');
zipFile.exists().then((value) async {
if (value == true) {
zipFile.delete().then((value) {
// FLog.info(text: 'existing file deleted');
_createZipAndShowMail(
destDir, dataDir, zipFile, body, appName);
});
} else {
_createZipAndShowMail(
destDir, dataDir, zipFile, body, appName);
}
});
});
}));
// });
//here
});
});
} on Exception catch (exception) {
FLog.error(text: 'exception while report bug :> ', exception: exception);
} catch (error) {
FLog.error(text: 'error while report bug : ${error.toString()}');
}
}