Coder Social home page Coder Social logo

kogalino / dart_app_data Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tobischw/dart_app_data

0.0 0.0 0.0 23 KB

Dart Package for getting commonly used locations for storage on Windows, Mac, and Linux, such as the app data directories.

License: MIT License

Dart 100.00%

dart_app_data's Introduction

Build Status

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 (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:

dependencies:
  dart_app_data: ^1.0.1

Usage

With AppData

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

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.

dart_app_data's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.