@@ -45,11 +45,11 @@ PathProviderPlatform get _platform => PathProviderPlatform.instance;
4545/// (and cleaning up) files or directories within this directory. This
4646/// directory is scoped to the calling application.
4747///
48- /// On iOS, this uses the `NSCachesDirectory` API.
48+ /// Example implementations:
49+ /// - `NSCachesDirectory` on iOS and macOS.
50+ /// - `Context.getCacheDir` on Android.
4951///
50- /// On Android, this uses the `getCacheDir` API on the context.
51- ///
52- /// Throws a `MissingPlatformDirectoryException` if the system is unable to
52+ /// Throws a [MissingPlatformDirectoryException] if the system is unable to
5353/// provide the directory.
5454Future <Directory > getTemporaryDirectory () async {
5555 final String ? path = await _platform.getTemporaryPath ();
@@ -63,15 +63,16 @@ Future<Directory> getTemporaryDirectory() async {
6363/// Path to a directory where the application may place application support
6464/// files.
6565///
66+ /// If this directory does not exist, it is created automatically.
67+ ///
6668/// Use this for files you don’t want exposed to the user. Your app should not
6769/// use this directory for user data files.
6870///
69- /// On iOS, this uses the `NSApplicationSupportDirectory` API.
70- /// If this directory does not exist, it is created automatically.
71- ///
72- /// On Android, this function uses the `getFilesDir` API on the context.
71+ /// Example implementations:
72+ /// - `NSApplicationSupportDirectory` on iOS and macOS.
73+ /// - The Flutter engine's `PathUtils.getFilesDir` API on Android.
7374///
74- /// Throws a ` MissingPlatformDirectoryException` if the system is unable to
75+ /// Throws a [ MissingPlatformDirectoryException] if the system is unable to
7576/// provide the directory.
7677Future <Directory > getApplicationSupportDirectory () async {
7778 final String ? path = await _platform.getApplicationSupportPath ();
@@ -86,10 +87,14 @@ Future<Directory> getApplicationSupportDirectory() async {
8687/// Path to the directory where application can store files that are persistent,
8788/// backed up, and not visible to the user, such as sqlite.db.
8889///
89- /// On Android, this function throws an [UnsupportedError] as no equivalent
90- /// path exists.
90+ /// Example implementations:
91+ /// - `NSApplicationSupportDirectory` on iOS and macOS.
92+ ///
93+ /// Throws an [UnsupportedError] if this is not supported on the current
94+ /// platform. For example, this is unlikely to ever be supported on Android,
95+ /// as no equivalent path exists.
9196///
92- /// Throws a ` MissingPlatformDirectoryException` if the system is unable to
97+ /// Throws a [ MissingPlatformDirectoryException] if the system is unable to
9398/// provide the directory on a supported platform.
9499Future <Directory > getLibraryDirectory () async {
95100 final String ? path = await _platform.getLibraryPath ();
@@ -102,14 +107,14 @@ Future<Directory> getLibraryDirectory() async {
102107/// Path to a directory where the application may place data that is
103108/// user-generated, or that cannot otherwise be recreated by your application.
104109///
105- /// On iOS, this uses the `NSDocumentDirectory` API. Consider using
106- /// [getApplicationSupportDirectory] instead if the data is not user-generated.
110+ /// Consider using another path, such as [getApplicationSupportDirectory] or
111+ /// [getExternalStorageDirectory] , if the data is not user-generated.
107112///
108- /// On Android, this uses the `getDataDirectory` API on the context. Consider
109- /// using [getExternalStorageDirectory] instead if data is intended to be visible
110- /// to the user .
113+ /// Example implementations:
114+ /// - `NSDocumentDirectory` on iOS and macOS.
115+ /// - The Flutter engine's `PathUtils.getDataDirectory` API on Android .
111116///
112- /// Throws a ` MissingPlatformDirectoryException` if the system is unable to
117+ /// Throws a [ MissingPlatformDirectoryException] if the system is unable to
113118/// provide the directory.
114119Future <Directory > getApplicationDocumentsDirectory () async {
115120 final String ? path = await _platform.getApplicationDocumentsPath ();
@@ -121,13 +126,13 @@ Future<Directory> getApplicationDocumentsDirectory() async {
121126}
122127
123128/// Path to a directory where the application may access top level storage.
124- /// The current operating system should be determined before issuing this
125- /// function call, as this functionality is only available on Android.
126129///
127- /// On iOS, this function throws an [UnsupportedError] as it is not possible
128- /// to access outside the app's sandbox .
130+ /// Example implementation:
131+ /// - `getExternalFilesDir(null)` on Android .
129132///
130- /// On Android this uses the `getExternalFilesDir(null)` .
133+ /// Throws an [UnsupportedError] if this is not supported on the current
134+ /// platform (for example, on iOS where it is not possible to access outside
135+ /// the app's sandbox).
131136Future <Directory ?> getExternalStorageDirectory () async {
132137 final String ? path = await _platform.getExternalStoragePath ();
133138 if (path == null ) {
@@ -136,19 +141,19 @@ Future<Directory?> getExternalStorageDirectory() async {
136141 return Directory (path);
137142}
138143
139- /// Paths to directories where application specific external cache data can be
140- /// stored. These paths typically reside on external storage like separate
141- /// partitions or SD cards. Phones may have multiple storage directories
142- /// available.
144+ /// Paths to directories where application specific cache data can be stored
145+ /// externally.
143146///
144- /// The current operating system should be determined before issuing this
145- /// function call, as this functionality is only available on Android .
147+ /// These paths typically reside on external storage like separate partitions
148+ /// or SD cards. Phones may have multiple storage directories available .
146149///
147- /// On iOS, this function throws an UnsupportedError as it is not possible
148- /// to access outside the app's sandbox.
150+ /// Example implementation:
151+ /// - Context.getExternalCacheDirs() on Android (or
152+ /// Context.getExternalCacheDir() on API levels below 19).
149153///
150- /// On Android this returns Context.getExternalCacheDirs() or
151- /// Context.getExternalCacheDir() on API levels below 19.
154+ /// Throws an [UnsupportedError] if this is not supported on the current
155+ /// platform. This is unlikely to ever be supported on any platform other than
156+ /// Android.
152157Future <List <Directory >?> getExternalCacheDirectories () async {
153158 final List <String >? paths = await _platform.getExternalCachePaths ();
154159 if (paths == null ) {
@@ -158,18 +163,19 @@ Future<List<Directory>?> getExternalCacheDirectories() async {
158163 return paths.map ((String path) => Directory (path)).toList ();
159164}
160165
161- /// Paths to directories where application specific data can be stored.
166+ /// Paths to directories where application specific data can be stored
167+ /// externally.
168+ ///
162169/// These paths typically reside on external storage like separate partitions
163170/// or SD cards. Phones may have multiple storage directories available.
164171///
165- /// The current operating system should be determined before issuing this
166- /// function call, as this functionality is only available on Android.
172+ /// Example implementation:
173+ /// - Context.getExternalFilesDirs(type) on Android (or
174+ /// Context.getExternalFilesDir(type) on API levels below 19).
167175///
168- /// On iOS, this function throws an UnsupportedError as it is not possible
169- /// to access outside the app's sandbox.
170- ///
171- /// On Android this returns Context.getExternalFilesDirs(String type) or
172- /// Context.getExternalFilesDir(String type) on API levels below 19.
176+ /// Throws an [UnsupportedError] if this is not supported on the current
177+ /// platform. This is unlikely to ever be supported on any platform other than
178+ /// Android.
173179Future <List <Directory >?> getExternalStorageDirectories ({
174180 /// Optional parameter. See [StorageDirectory] for more informations on
175181 /// how this type translates to Android storage directories.
@@ -185,10 +191,12 @@ Future<List<Directory>?> getExternalStorageDirectories({
185191}
186192
187193/// Path to the directory where downloaded files can be stored.
188- /// This is typically only relevant on desktop operating systems.
189194///
190- /// On Android and on iOS, this function throws an [UnsupportedError] as no equivalent
191- /// path exists.
195+ /// The returned directory is not guaranteed to exist, so clients should verify
196+ /// that it does before using it, and potentially create it if necessary.
197+ ///
198+ /// Throws an [UnsupportedError] if this is not supported on the current
199+ /// platform.
192200Future <Directory ?> getDownloadsDirectory () async {
193201 final String ? path = await _platform.getDownloadsPath ();
194202 if (path == null ) {
0 commit comments