getApplicationSupportDirectory function Null safety

Future<Directory> getApplicationSupportDirectory()

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

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

On iOS, this uses the NSApplicationSupportDirectory API. If this directory does not exist, it is created automatically.

On Android, this function uses the getFilesDir API on the context.

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


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

  return Directory(path);