https://github.com/tobischw/dart_app_data
Dart Package for getting commonly used locations for storage on Windows, Mac, and Linux, such as the app data directories.
https://github.com/tobischw/dart_app_data
appdata dart linux storage
Last synced: 7 months ago
JSON representation
Dart Package for getting commonly used locations for storage on Windows, Mac, and Linux, such as the app data directories.
- Host: GitHub
- URL: https://github.com/tobischw/dart_app_data
- Owner: tobischw
- License: mit
- Created: 2019-08-25T22:21:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T18:10:41.000Z (almost 4 years ago)
- Last Synced: 2025-06-13T01:48:59.528Z (9 months ago)
- Topics: appdata, dart, linux, storage
- Language: Dart
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/tobischw/dart_app_data)
# dart_app_data
Dart Package for getting commonly used locations for storage on Windows, Mac, and Linux, such as the app data directories.
Inspired by [path_provider](https://pub.dev/packages/path_provider) (this does the same, except for Dart CLI apps or libs).
Originally written for a locally cached repository (think .m2 cache for Java). Tested and working on Windows, Mac, and Linux. **Flutter is not supported.**
## Notice
Not tested on Windows 7/Vista/older, this library could use improvements! It's also a bit overkill for what basically amounts to a Platform.is()... call and a simple string concatenation, so I am looking for ideas on features to add. You can also just take a look at Locator.dart and copy the code from there instead of pulling in the entire package.
## How to Install
Add this to your package's pubspec.yaml file:
```yml
dependencies:
dart_app_data: ^1.0.1
```
## Usage
### With AppData
```dart
import 'package:dart_app_data/dart_app_data.dart';
...
// Creates a folder if it does not already exist (only call once).
final myData = AppData.findOrCreate('.my_app');
// Get the location of the folder as a String
print(myData.path); // Outputs: C:\Users\MyUsername\AppData\Roaming\.my_app
// Get the location of the folder directly as a directory
print(myData.directory);
// Get the name of the cache
print(myData.name); // Outputs: .my_app
// ... Do whatever you want with the folder now.
// Want to delete it?
// myData.delete();
```
### Without AppData
```dart
import 'package:dart_app_data/src/locator.dart';
...
// No need for the AppData abstraction? Use the Locator helper.
print(Locator.getPlatformSpecificCachePath());
// Outputs: C:\Users\MyUsername\AppData\Roaming
```
# Troubleshooting
```
LocatorException: App caches are not supported for mobile devices
```
As the message says, this package is only for Dart applications that run on a traditional
operating system (such as Windows, Linux, Mac).
```
LocatorException: The user application path for this platform ("$path") does not exist on this system
```
Something went wrong during the path discovery (i.e.: the path does not exist). Is the app running as root? Did you a delete a common path somehow (see below)? Submit an Issue if this persists.
```
LocatorException: Platform-specific cache path for platform "$os" was not found
```
This means you're on an unsupported operating system.
# Paths
* Windows: C:\Users\MyUsername\AppData\Roaming
* macOS: /MyUsername/Library/Application Support
* Linux: /MyUsername/user/
# License
See `LICENSE` in repository.