Skip to content

Instantly share code, notes, and snippets.

@telenieko
Last active March 15, 2022 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telenieko/f5fa8437fc8fbf7454ef052527308deb to your computer and use it in GitHub Desktop.
Save telenieko/f5fa8437fc8fbf7454ef052527308deb to your computer and use it in GitHub Desktop.
Difference between `Uri.path` and `Uri.toFilePath()` on Windows
// Example for <https://github.com/dart-lang/markdown/pull/396>
void main() {
final fileUriUnix =
Uri.file(r'/home/myself/images/image.png', windows: false);
print(fileUriUnix.path); // /home/myself/images/image.png
print(fileUriUnix.toFilePath()); // /home/myself/images/image.png
final fileUriWindows =
Uri.file(r'C:\Users\myself\Documents\image.png', windows: true);
print(fileUriWindows.path); // /C:/Users/myself/Documents/image.png
print(fileUriWindows.toFilePath(
windows: true)); // C:\Users\myself\Documents\image.png
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment