getTemporaryDirectory function
Path to the temporary directory on the device that is not backed up and is suitable for storing caches of downloaded files.
Files in this directory may be cleared at any time. This does not return a new temporary directory. Instead, the caller is responsible for creating (and cleaning up) files or directories within this directory. This directory is scoped to the calling application.
Example implementations:
NSCachesDirectory
on iOS and macOS.Context.getCacheDir
on Android.
Throws a MissingPlatformDirectoryException if the system is unable to provide the directory.
Implementation
Future<Directory> getTemporaryDirectory() async {
final String? path = await _platform.getTemporaryPath();
if (path == null) {
throw MissingPlatformDirectoryException(
'Unable to get temporary directory');
}
return Directory(path);
}