这是我用来创建文件夹的函数的代码。
注意:我已经使用。exist函数测试了文件夹是否存在,并且它已经存在,但我无法在文件管理器应用程序中找到它。
Future<String> getFilePath() async {
Directory endPointDirectory=Directory("");
const String folderName="cameraFlutter";// there folder where we will save files to it
var directory=getExternalStorageDirectory()
.then((value) async {
final Directory endPointDirectory=Directory("${value!.path}/$folderName");
if (await endPointDirectory.exists()) {
print("exist");
print(endPointDirectory.path);
} else {
//if folder not exists create folder and then return its path
print("not exist");
await endPointDirectory.create();
}
}).catchError((onError){
print(onError.toString());
});
return endPointDirectory.path;//external storage directory
}
输入图片描述
直接打印查看路径
...
....
final Directory endPointDirectory = Directory("${value!.path}/$folderName");
print(endPointDirectory);
....
...