fileIn method

File fileIn(
  1. String directory,
  2. PretrainedModel model
)

Where download will put model inside directory.

Useful for checking whether the model is already in place without touching the network.

The name is joined on rather than resolved as a URI, which would normalize .. by text — a/../b is b only when a is not a symlink, and the kernel that later creates the directory knows that and a URI does not. An empty directory means the working directory.

Implementation

File fileIn(String directory, PretrainedModel model) {
  if (directory.isEmpty) {
    return File(model.fileName);
  }

  final separator =
      directory.endsWith(Platform.pathSeparator) || directory.endsWith('/')
      ? ''
      : Platform.pathSeparator;

  return File('$directory$separator${model.fileName}');
}