Kapitan
Kapitan

Reputation: 83

Flutter crossplatform storage directory

I struggle to find some package...

is there some way how to ask for some good default storage location? (Config and ini files...) As flutter gives me the possibility to run on all possible platforms I would like a really simple cross-platform solution. Something that would give me /home/user for linux, /Users/user for osx ... without worrying about plaform.

Upvotes: 0

Views: 399

Answers (1)

MCB
MCB

Reputation: 876

Try the Path_Provider package: https://pub.dev/packages/path_provider

add this to your pubspec.yaml:

path_provider: ^2.0.11

get default storage:

Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;

Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;

Upvotes: 1

Related Questions