Skip to content

[path_provider] A way to get the current user's cache directory on desktop #105386

@cachapa

Description

@cachapa

Use case

Out app can potentially download a lot of media to show locally. We cache this data locally to avoid unnecessary round-trips.
We try to store the data in a platform-standard cache directory so that it can be cleared by the system e.g. when the system is running out of space.

On Linux the proper place to store the data would be in the user's ~/.cache directory, but there's currently no way to retrieve it from path_provider.
I believe there are equivalent directories on macOS (~/Library/Caches?) and Windows (%LOCALAPPDATA%?).

The closest candidate is getTemporaryDirectory() which (on my Linux system) returns /tmp, potentially exposing the user's data in multiuser systems.

Proposal

A new method called getApplicationCacheDirectory() analogous to the Android-only getExternalCacheDirectories().
That method could also return the first result of getExternalCacheDirectories() on Android, since it seems to always point to the current user's /sdcard/android/data/$app_id/cache.

Note: I'm willing to do this work for Linux and Android but I wanted to discuss it before starting the effort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopc: proposalA detailed proposal for a change to Flutterfyi-linuxFor the attention of the Linux platform teamfyi-macosFor the attention of macOS platform teamfyi-windowsFor the attention of the Windows platform teamp: path_providerPlugin that provides resolved paths to some platform directoriespackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions