prettyUri function
- 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.cn/'); // -> 'https://dart.cn'
// Windows at "C:\root\path"
p.prettyUri('file:///C:/root/path/a/b.dart'); // -> r'a\b.dart'
p.prettyUri('https://dart.cn/'); // -> 'https://dart.cn'
// URL at "https://dart.cn/root/path"
p.prettyUri('https://dart.cn/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!);