useAppDocumentsDir static method

Future<void> useAppDocumentsDir()

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

Implementation

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

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