Search code examples
mobiledartflutter

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.

Does anyone know of a way to get the fee storage space a device has for both iPhone and Android?


Solution

  • 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; on iOS use volumeAvailableCapacityForOpportunisticUsageKey.