【问题标题】:How to show size of file from file path in flutter如何在颤振中显示文件路径中的文件大小
【发布时间】:2022-11-24 15:28:11
【问题描述】:

我试图从设备存储中获取所有 pdf 文件,现在完成了我想在列表视图中显示该文件的大小。生成器尾随。

我的文件路径

files[index].path

文件 [index].path 的打印是 /storage/emulated/0/android/data/......../name.pdf

【问题讨论】:

    标签: flutter dart flutter-dependencies flutter-animation dart-pub


    【解决方案1】:

    Get file size here

    并使用此包获取人类可读的文件大小字符串

    https://pub.dev/packages/filesize

    【讨论】:

    • 试过不工作
    【解决方案2】:

    如果你的列表类型是File,你可以用length()得到:

    var size = await files[index].length();
    print(size);
    

    【讨论】:

    • 无法调用它显示的长度函数找不到要转到的声明
    • 将鼠标悬停在列表上时,列表的类型是什么? @FaizanAbbasBangash
    • 文件............
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    • 2018-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    相关资源
    最近更新 更多