我正在 flutter 中构建一个文件储物柜应用程序,它可以锁定文件和文件夹。当用户解锁文件夹时,我希望我的应用程序显示一个在本机文件资源管理器中查看文件夹内容的选项。有什么办法可以实现这个功能吗?
(提前感谢..)
您可以针对您提到的用例尝试此包:open_file
用途:
import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
//Get the path to the directory
final String dir = (await getTemporaryDirectory()).path;
//Use the path to launch the directory with the native file explorer
await OpenFile.open('$dir\\');
(注: 仅在 Windows 操作系统上测试)
如果您想在 Android 上进行测试,请使用另一个目录,例如
getExternalStorageDirectory
,因为 getTemporaryDirectory
在您的应用程序沙箱之外无法访问。