Here is the setup in side of my
pubspec.yaml
...
path_provider: ^0.4.1
assets:
- assets/
- assets/a.txt
...
I try to find way to access to the "assets" directory to read content of the text file named "a.txt" where it should read in relative way as "assets/a.txt". Here is my code in my main.dart:
Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
String fPath = '${appDocDir.parent.path}/assets/a.txt';
new File(fPath).readAsString().then((String contents) {
print("FILE:..... "+contents);
});
And here I got this error:
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
FileSystemException: Cannot open file, path = '/var/mobile/Containers/Data/Application/EE2A0E91-6543-4CE3-A82B-3B69BB892BFC/assets/a.txt' (OS Error: No such file or directory, errno = 2)
Seem like the ... EE2A0E91-6543-4CE3-A82B-3B69BB892BFC/ is not the root directory of the app to concat with my file assets/a.txt.
How can I find the exact absolute path of my a.txt file in order to read it using File() class?