flutterFlutter开发圈

Flutter之path_provider

2019-02-14  本文已影响1人  习惯了_就好
/**
 * 1.在pubspec.yaml文件中声明依赖 PathProvider 插件
 *   dependencies:
 *   path_provider: ^0.5.0+1
 * 2.在pubspec.yaml顶部的动作功能区中点击“Packages Get”
 *
 * getExternalStorageDirectory,在iOS上,抛出异常,在Android上,这是getExternalStorageDirectory的返回值
 * getTemporaryDirectory,在iOS上,对应NSTemporaryDirectory()返回的值,在Android上,这是getCacheDir的返回值。
 * getApplicationDocumentsDirectory,在iOS上,这对应NSDocumentsDirectory,在Android上,这是AppData目录
 */
body: ListView(
          children: <Widget>[
            MyRowText("获取sd卡的根路径", ()async{
              String sDCardDir = (await getExternalStorageDirectory()).path;
              debugPrint(sDCardDir);
            }),
            MyRowText("获取临时目录的路径", ()async{
              String sTempDir = (await getTemporaryDirectory()).path;
              debugPrint(sTempDir);
            }),
            MyRowText("获取文档目录的路径", ()async{
              String sDocumentDir = (await getApplicationDocumentsDirectory()).path;
              debugPrint(sDocumentDir);
            }),
          ],
        ),
上一篇 下一篇

猜你喜欢

热点阅读