createFolderByPath function
Create folder by path
- i.e:
.createFolderByPath("/storage/emulated/0/", "folder name" )
Supply path alone to create by already combined path, or path + filename to be combined
Implementation
Future<Directory> createFolderByPath(String path, {String? folderName}) async {
print("filesystem_utils->createFolderByPath: $folderName @ $path");
var _directory;
if (folderName != null) {
_directory = Directory(pathlib.join(path, folderName));
} else {
_directory = Directory(path);
}
try {
if (!_directory.existsSync()) {
_directory.create();
} else {
FileSystemException("File already exists");
}
return _directory;
} catch (e) {
throw FileSystemException(e as String);
}
}