@@ -247,12 +247,28 @@ class FilePickerWritable {
247247 });
248248 }
249249
250+ /// See if the the directory picker and directory tree access is supported on
251+ /// the current platform. If this returns `false` then [openDirectory] ,
252+ /// [getDirectory] , and [resolveRelativePath] will fail with an exception.
253+ Future <bool > isDirectoryAccessSupported () async {
254+ _logger.finest ('isDirectoryAccessSupported()' );
255+ final result =
256+ await _channel.invokeMethod <bool >('isDirectoryAccessSupported' );
257+ if (result == null ) {
258+ throw StateError ('Error while checking if directory access is supported' );
259+ }
260+ return result;
261+ }
262+
250263 /// Shows a directory picker so the user can select a directory.
251264 ///
252265 /// [initialDirUri] is the URI indicating where the picker should start by
253266 /// default. This is only honored on a best-effort basis and even then is not
254267 /// supported on all systems. It can be a [FileInfo.uri] or a
255268 /// [DirectoryInfo.uri] .
269+ ///
270+ /// An exception will be thrown if invoked on a system that does not support
271+ /// directory access, i.e. if [isDirectoryAccessSupported] returns `false` .
256272 Future <DirectoryInfo ?> openDirectory ({String ? initialDirUri}) async {
257273 _logger.finest ('openDirectoryPicker()' );
258274 final result = await _channel.invokeMapMethod <String , String >(
@@ -296,6 +312,9 @@ class FilePickerWritable {
296312 ///
297313 /// [rootIdentifier] should be a [DirectoryInfo.identifier] obtained from
298314 /// [pickDirectory] . [fileIdentifier] should be a [FileInfo.identifier] .
315+ ///
316+ /// An exception will be thrown if invoked on a system that does not support
317+ /// directory access, i.e. if [isDirectoryAccessSupported] returns `false` .
299318 Future <DirectoryInfo > getDirectory ({
300319 required String rootIdentifier,
301320 required String fileIdentifier,
@@ -316,6 +335,9 @@ class FilePickerWritable {
316335 ///
317336 /// [directoryIdentifier] should be a [DirectoryInfo.identifier] obtained from
318337 /// [pickDirectory] or [getDirectory] .
338+ ///
339+ /// An exception will be thrown if invoked on a system that does not support
340+ /// directory access, i.e. if [isDirectoryAccessSupported] returns `false` .
319341 Future <EntityInfo > resolveRelativePath ({
320342 required String directoryIdentifier,
321343 required String relativePath,
0 commit comments