tryCreate method
Tries to create a directory at path. Never throws.
Implementation
Future<bool> tryCreate() async {
try {
var type = await fs.type(path);
if (type == FileSystemEntityType.directory) {
return true;
} else if (type != FileSystemEntityType.notFound) {
return false;
}
final dir = directory(path);
await dir.create(recursive: true);
return true;
} on FileSystemException catch (e) {
// ignore
if (e.status == FileSystemException.statusAlreadyExists) {
return true;
}
} catch (_) {
// ignore any error
}
return false;
}