Flutter之path_provider

作者: 习惯了_就好 | 来源:发表于2019-02-14 09:28 被阅读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);
            }),
          ],
        ),

相关文章

网友评论

    本文标题:Flutter之path_provider

    本文链接:https://www.haomeiwen.com/subject/ubeseqtx.html