fromUri function

String fromUri(
  1. Object? uri
)

Returns the path represented by uri, which may be a String or a Uri.

For POSIX and Windows styles, uri must be a file: URI. For the URL style, this will just convert uri to a string.

// POSIX
p.fromUri('file:///path/to/foo') // -> '/path/to/foo'

// Windows
p.fromUri('file:///C:/path/to/foo') // -> r'C:\path\to\foo'

// URL
p.fromUri('https://dart.cn/path/to/foo')
  // -> 'https://dart.cn/path/to/foo'

If uri is relative, a relative path will be returned.

p.fromUri('path/to/foo'); // -> 'path/to/foo'

Implementation

String fromUri(Object? uri) => context.fromUri(uri!);