简体   繁体   English

如何获得设备的免费和已用存储空间

[英]How to get a device's free & used storage space

I'm using a flutter for a new project and everything's been great until today.我正在为一个新项目使用颤振,直到今天一切都很好。

The app we're building allows our employees to download and view some internal file types on their devices.我们正在构建的应用程序允许我们的员工在他们的设备上下载和查看一些内部文件类型。 One feature request we have gotten is to show how much storage space the device has left.我们收到的一项功能请求是显示设备剩余多少存储空间。 Some of our employees download a lot of files and keep running out of space.我们的一些员工下载了大量文件并不断耗尽空间。 I tried searching for a way to do this but I can't find anything.我试图寻找一种方法来做到这一点,但我找不到任何东西。 It's the first time so far I've been completely blocked using Flutter.到目前为止,这是我第一次被 Flutter 完全屏蔽。

Does anyone know of a way to get the fee storage space a device has for both iPhone and Android?有谁知道如何获得 iPhone 和 Android 设备的费用存储空间?

This is a perfect use case for platform channels which could be part of your main project, or implemented in a plugin .这是平台通道的完美用例,它可以是您的主要项目的一部分,也可以在插件中实现。

On Android, use StatFs ;在 Android 上,使用StatFs on iOS use volumeAvailableCapacityForOpportunisticUsageKey .在 iOS 上使用volumeAvailableCapacityForOpportunisticUsageKey

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM