-
pub 地址:https://pub.flutter-io.cn/packages/path_provider
-
Github 地址:https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider
2.2 插件安装
切换到终端模式下,执行如下指令
flutter pub add path_provider
点击pubspec.yaml右上角的Pub get
或者执行如下指令
flutter pub get
path_provider.dart文件下提供了8中获取文件路径的方法
3.1 getTemporaryDirectory
-
临时目录,适用于下载的缓存文件,此目录随时可以清除
-
此目录为应用程序私有目录,其他应用程序无法访问此目录
-
Android 上对应
getCacheDir
;iOS上对应NSCachesDirectory
3.2 getApplicationSupportDirectory
-
应用程序可以在其中放置应用程序支持文件的目录的路径
-
将此文件用于您不想向用户公开的文件。 您的应用不应将此目录用于存放用户数据文件
-
在iOS上,对应
NSApplicationSupportDirectory
,如果此目录不存在,则会自动创建。 在Android上,对应getFilesDir