file static method

Uri file(
  1. String path
)

Create an URI from a file system path. The {@link Uri.schemescheme} will be file.

The difference between {@link Uri.parse} and {@link Uri.file} is that the latter treats the argument as path, not as stringified-uri. E.g. Uri.file(path) is not the same as Uri.parse('file://' + path) because the path might contain characters that are interpreted (# and ?). See the following sample:

const good = URI.file('/coding/c#/project1');
good.scheme === 'file';
good.path === '/coding/c#/project1';
good.fragment === '';

const bad = URI.parse('file://' + '/coding/c#/project1');
bad.scheme === 'file';
bad.path === '/coding/c'; // path is now broken
bad.fragment === '/project1';

Implementation

static _i3.Uri file(_i2.String path) => _i5.callMethod(
      _declaredUri,
      'file',
      [path],
    );