Open hari-seafoodsouq opened 1 month ago
Can you check that iOS app has necessary permissions to write and read device storage? Try using this for IOS: logsExportDirectoryName: "${externalDirectory?.path}/MyLogs/Exported",
Can you check that iOS app has necessary permissions to write and read device storage? Try using this for IOS: logsExportDirectoryName: "${externalDirectory?.path}/MyLogs/Exported",
Hi Shubyaa,
Thanks for the response. i tried using above code it didn't work as well.
This is how the code is when the share button is clicked where it's working fine for android and in ios the file is not created in the first place.
onPressed: () async { Directory? externalDirectory; if (Platform.isIOS) { externalDirectory = await getApplicationDocumentsDirectory(); } else { externalDirectory = await getExternalStorageDirectory(); } final fileDirectory = Directory('${externalDirectory?.path}/MyLogs/Logs');
try {
final zipFilePath = "${externalDirectory?.path}/log.zip";
final zipFile = File(zipFilePath);
if (zipFile.existsSync()) {
zipFile.deleteSync();
}
await ZipFile.createFromDirectory(
sourceDir: fileDirectory, zipFile: zipFile, recurseSubDirs: true);
await Share.shareXFiles(
[XFile(zipFile.path)],
subject: 'Share log file',
text: 'Hello, check your share files!',
);
} catch (e) {
print('Error: $e');
LogHelper.logs(e.toString());
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text('Error sharing logs: $e')),
// );
}
},
Kindly help me to fix this!
What errors you got while performing the code within try catch ? can you paste that error here?
Console: flutter: Error: PlatformException(ZIP_ERROR, The file “Logs” couldn’t be opened because there is no such file., null, null) flutter: flutter_logs: {} {} {PlatformException(ZIP_ERROR, The file “Logs” couldn’t be opened because there is no such file., null, null)} {INFO}
Initialising in main code: await FlutterLogs.initLogs( logLevelsEnabled: [ LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE ], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.SINGLE_FILE_FOR_DAY, logFileExtension: LogFileExtension.TXT, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, );
The error says that the Flutter is looking for the file Logs, but in your initLogs
, nothing is mentioned as Logs. Please check that from where the filename Logs is given.
I initialise as: await FlutterLogs.initLogs( logLevelsEnabled: [ LogLevel.INFO, LogLevel.WARNING, LogLevel.ERROR, LogLevel.SEVERE ], timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE, directoryStructure: DirectoryStructure.SINGLE_FILE_FOR_DAY, logFileExtension: LogFileExtension.TXT, logsWriteDirectoryName: "MyLogs", logsExportDirectoryName: "MyLogs/Exported", debugFileOperations: true, isDebuggable: true, );
I check it like this:
if (Platform.isIOS) { externalDirectory = await getApplicationDocumentsDirectory();
I get an output stating "file doesn't exist" i want to know where is it getting stored and how can we see it. It works fine on android.