useAppCacheDir static method

Future<void> useAppCacheDir()

If running from Flutter, the base directory will be the application's cache directory. If running from tests, it will use the system's temp directory.

Implementation

static Future<void> useAppCacheDir() async {
  if (_baseDirectory != null) return;

  if (_fileSystem == const LocalFileSystem()) {
    try {
      _baseDirectory = await getApplicationCacheDirectory();
    } on MissingPluginException catch (_) {
      _baseDirectory = const LocalFileSystem().systemTempDirectory;
    }
  } else
    _baseDirectory = _fileSystem.systemTempDirectory;
}