getLibraryDirectory function

Future<Directory> getLibraryDirectory()

Path to the directory where application can store files that are persistent, backed up, and not visible to the user, such as sqlite.db.

Example implementations:

  • NSApplicationSupportDirectory on iOS and macOS.

Throws an UnsupportedError if this is not supported on the current platform. For example, this is unlikely to ever be supported on Android, as no equivalent path exists.

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

Implementation

Future<Directory> getLibraryDirectory() async {
  final String? path = await _platform.getLibraryPath();
  if (path == null) {
    throw MissingPlatformDirectoryException('Unable to get library directory');
  }
  return Directory(path);
}