useAppDownloadsDir static method

Future<void> useAppDownloadsDir()

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

Implementation

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

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