In order to determine if there is enough device storage to download images, it is possible to check device storage in Flutter without having to do this natively.
- Add the
dependencies: path_provider: ^1.6.11
- Import the package:
- Use the
getExternalStorageDirectory()method to obtain the root directory of external storage. Then use the
list()method to get the list of files and folders, and the
Stat()method to get the size of a file or folder.
final directory = await getExternalStorageDirectory(); final files = directory.list(); final size = files.stat().size;