How to read files outside the project's directory - flutter

I'm new to flutter,I want to read some files outide the directory of my flutter project,let's say a file located in Desktop folder
here's how I tried
Future<File> _getLocalFile() async {
return File('/Users/xxx/Desktop/test.txt');
}
then I got this error
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FileSystemException: Cannot open file, path = '/Users/xxx/Desktop/test.txt' (OS Error: Operation not permitted, errno = 1)
Is there any way I can get the permission to deal with such files?

Related

Flutter :FileSystemException: Directory listing failed, path = '/storage/emulated/0/Android/data' (OS Error: Permission denied, errno = 13)

i am getting all pdf from device storage but after android 9 it mbile shows different eroors and all are same like exclude path = '/storage/emulated/0/Android/data . So how can i exclude all those path that create run time error

Gallery saver catches (OS Error: File name too long, errno = 36))

I'm trying to save an image to the Android gallery and catch this exception:
FileSystemException (FileSystemException: Cannot open file, path = '/data/user/0/...' (OS Error: File name too long, errno = 36)).
How to solve this problem?

How to get rid of tthe following error --Failed to save Chrome preferences: FileSystemException: Cannot open file ,path='C:\Users\HP\AppDate/Local?

When I run my application with the command flutter run -d chrome,my app is establishing connection with chrome,but the browser is blank and i cant see any content in browser,in the console it throws the following error
Failed to save Chrome preferences: FileSystemException: Cannot open file, path =
'C:\Users\HP\AppData\Local\Temp\flutter_tools.78af2e68\flutter_tools_chrome_device.ff7bb79d\Default\Cache\data_0' (OS Error: The process cannot
access the file because it is being used by another process.
, errno = 32)

what is flutter app default path in macos?

Use flutter dev app with macos desktop.
One local file: test1.md
In Dart code, I cann't find local file: test1.md
try
print(readText("test1.md"));
Exception has occurred:
FileSystemException (FileSystemException: Cannot open file, path = 'test1.md' (OS Error: No such file or directory, errno = 2))
print(Directory.current);
Output:
flutter: Directory: '/Users/jiangzhixiang/Library/Containers/com.example.enjoywork/Data'
How to find local file?

"FileSystemException: Cannot open file, path = 'C:\Users\flutter\bin\cache\lockfile' (OS Error: Access is denied

"FileSystemException: Cannot open file, path = 'C:\Users\flutter\bin\cache\lockfile' (OS Error: Access is denied.
This message occurred while flutter doctor command.