in lib/src/style/windows.dart [105:141]
Uri absolutePathToUri(String path) {
final parsed = ParsedPath.parse(path, this);
if (parsed.root!.startsWith(r'\\')) {
// Network paths become "file://server/share/path/to/file".
// The root is of the form "\\server\share". We want "server" to be the
// URI host, and "share" to be the first element of the path.
final rootParts = parsed.root!.split('\\').where((part) => part != '');
parsed.parts.insert(0, rootParts.last);
if (parsed.hasTrailingSeparator) {
// If the path has a trailing slash, add a single empty component so the
// URI has a trailing slash as well.
parsed.parts.add('');
}
return Uri(
scheme: 'file', host: rootParts.first, pathSegments: parsed.parts);
} else {
// Drive-letter paths become "file:///C:/path/to/file".
// If the path is a bare root (e.g. "C:\"), [parsed.parts] will currently
// be empty. We add an empty component so the URL constructor produces
// "file:///C:/", with a trailing slash. We also add an empty component if
// the URL otherwise has a trailing slash.
if (parsed.parts.isEmpty || parsed.hasTrailingSeparator) {
parsed.parts.add('');
}
// Get rid of the trailing "\" in "C:\" because the URI constructor will
// add a separator on its own.
parsed.parts
.insert(0, parsed.root!.replaceAll('/', '').replaceAll('\\', ''));
return Uri(scheme: 'file', pathSegments: parsed.parts);
}
}