getApplicationSupportDirectory function

Future<Directory> getApplicationSupportDirectory()

Path to a directory where the application may place application support files.

If this directory does not exist, it is created automatically.

Use this for files you don’t want exposed to the user. Your app should not use this directory for user data files.

Example implementations:

  • NSApplicationSupportDirectory on iOS and macOS.
  • The Flutter engine's PathUtils.getFilesDir API on Android.

Throws a MissingPlatformDirectoryException if the system is unable to provide the directory.

Implementation

Future<Directory> getApplicationSupportDirectory() async {
  final String? path = await _platform.getApplicationSupportPath();
  if (path == null) {
    throw MissingPlatformDirectoryException(
        'Unable to get application support directory');
  }

  return Directory(path);
}