prettyUri function

String prettyUri(
  1. Object? uri
)

Returns a terse, human-readable representation of uri.

uri can be a String or a Uri. If it can be made relative to the current working directory, that's done. Otherwise, it's returned as-is. This gracefully handles non-file: URIs for Style.posix and Style.windows.

The returned value is meant for human consumption, and may be either URI- or path-formatted.

// POSIX at "/root/path"
p.prettyUri('file:///root/path/a/b.dart'); // -> 'a/b.dart'
p.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'

// Windows at "C:\root\path"
p.prettyUri('file:///C:/root/path/a/b.dart'); // -> r'a\b.dart'
p.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'

// URL at "https://dart.dev/root/path"
p.prettyUri('https://dart.dev/root/path/a/b.dart'); // -> r'a/b.dart'
p.prettyUri('file:///root/path'); // -> 'file:///root/path'

Implementation

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