isDirWritable function
Whether dir is writable by creating and deleting a probe file.
Implementation
bool isDirWritable(Directory dir) {
if (!dir.existsSync()) {
return false;
}
try {
final File probe = File(
'${dir.path}${Platform.pathSeparator}.adk_probe_${DateTime.now().microsecondsSinceEpoch}',
);
probe.writeAsStringSync('probe');
probe.deleteSync();
return true;
} on FileSystemException {
return false;
}
}