Preserve file date (mtime) for images/files picked
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Use case
When picking a file or files, it's often useful to know when the original file was created/edited. This allows features like sorting by date as well as by file name. Unfortunately, at least on Android, the last edit date (mtime) of the temp file returned from image_picker has the date/time of when the file was selected and I haven't yet found any way to access the original file's last edit date.
### Proposal
final XFile? tmpFile = await ImagePicker().pickImage(
source: ImageSource.gallery,
preserveOriginalMtime = true,
);
if (tmpFile == null) {
return null;
}
final lastModifiedObject = await tmpFile.lastModified();
// prints modified time of original file instead of "right now"
print("Last Modified: " + lastModifiedObject.toString());
/******************************/
// Implementation, could be approximated by something like
if (preserveOriginalMtime == true) {
await touch(newTmpFile, await fileMtime(originalFile));
}
Contributor guide
Assessment
This issue has not been assessed yet.