Last active
March 15, 2022 13:56
-
-
Save telenieko/f5fa8437fc8fbf7454ef052527308deb to your computer and use it in GitHub Desktop.
Difference between `Uri.path` and `Uri.toFilePath()` on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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