-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdoc_man_app_dirs.dart
More file actions
68 lines (60 loc) · 2.66 KB
/
doc_man_app_dirs.dart
File metadata and controls
68 lines (60 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import 'dart:io' show Directory;
import 'package:docman/src/methods/app_dirs.dart';
/// Entry point for getting application directories,
/// like `cache`, `files`, `data`, `cacheExt`, and `filesExt`.
/// {@category DocMan}
class DocManAppDirs {
/// Get Application Cache Directory.
///
/// The directory for storing temporary cache files.
/// Returns [Directory] with proper path.
/// Path Example: `/data/user/0/devdf.plugins.docman_example/cache`
Future<Directory?> cache() => AppDir.cache.asDir();
/// Get Application Files Directory.
///
/// The directory for storing files, rarely used.
/// Returns [Directory] with proper path.
/// Path Example: `/data/user/0/devdf.plugins.docman_example/files`
Future<Directory?> files() => AppDir.files.asDir();
/// Get Application Data Directory.
///
/// Default Directory for storing data files of the app.
/// Returns [Directory] with proper path.
/// Path Example: `/data/user/0/devdf.plugins.docman_example/app_flutter`
Future<Directory?> data() => AppDir.data.asDir();
/// Get Application Cache External Directory.
///
/// The directory for storing temporary cache files on external storage.
/// Returns [Directory] with proper path.
/// Path Example: `/storage/emulated/0/Android/data/devdf.plugins.docman_example/cache`
Future<Directory?> cacheExt() => AppDir.cacheExt.asDir();
/// Get Application Files External Directory.
///
/// The directory for storing files on external storage.
/// Returns [Directory] with proper path.
/// Path Example: `/storage/emulated/0/Android/data/devdf.plugins.docman_example/files`
Future<Directory?> filesExt() => AppDir.filesExt.asDir();
/// Clear Temporary Cache Directories.
///
/// Clears only the temp directories created by the plugin like `docManMedia` and `docMan`
/// in external & internal cache directories if exists.
///
/// Returns `true` if the directories were cleared successfully, otherwise `false`.
Future<bool> clearCache() => AppDir.cache.clear();
/// Get all application directories (paths) at once.
///
/// Returns a map of all the app directories.
/// Only the values of `cacheExt` & `filesExt` can be empty Strings.
///
/// Result Example:
/// ```dart
/// {
/// "cache": "/data/user/0/devdf.plugins.docman_example/cache",
/// "files": "/data/user/0/devdf.plugins.docman_example/files",
/// "data": "/data/user/0/devdf.plugins.docman_example/app_flutter",
/// "cacheExt": "/storage/emulated/0/Android/data/devdf.plugins.docman_example/cache",
/// "filesExt": "/storage/emulated/0/Android/data/devdf.plugins.docman_example/files"
/// }
/// ```
Future<Map<String, String>?> all() => AppDir.all();
}