Accessing the filesystem, part 1 – path_provider
The first step whenever you need to write files to your device is knowing where to save those files. In this recipe, we will create an app that shows the current system's temporary and document directories.
path_provider
is a library that allows you to find common paths in your device, regardless of the operating system your app is running on. For example, on iOS and Android, the path of the document is different. By leveragingpath_provider
, you don't need to write two different methods based on the OS you are using; you just get the path by using the library's methods.- The
path_provider
library currently supports Android, iOS, Windows, macOS, and Linux. Check out https://pub.dev/packages/path_provider for the updated OS support list.
Getting ready
To follow along with this recipe, you must create a new app or update the code from the previous recipe.
How to do it...
To use path_provider
in your app, follow these...