given the code below
import 'dart:convert';
import 'dart:io';
void main() {
print('open file');
final path = stdin.readLineSync(encoding: utf8);
if (path == null) {
throw Exception('no path provided');
}
final uri = Uri.tryParse(path);
if (uri == null) {
throw Exception('invalid uri');
}
final file = File.fromUri(uri);
if (file.existsSync()) {
print(file.readAsStringSync());
return;
}
throw ('file not found: ${uri.path}');
}
if I run the commands below
dart run bin/console_test.dart
open file
~/Desktop/test_folder/readme.md
I get the error file not found: ~/Desktop/test_folder/readme.md
but a normal cat
command open the file easily
cat ~/Desktop/test_folder/readme.md
hello world!%
what am I missing?