flutterfiledartvisual-studio-codegpx

Flutter Dart File path


quick Flutter Dart issue.

I am trying to read from a text file located inside the app's directory, however Flutter does not recognize a single file path that I provide it. The file path is always responded to with "OS Error: No such file or directory, errno = 2".

I am trying to read from a file located in assets/importfiles, from a dart class inside lib/viewmodels. The assets directory has already been added to pubsec.yaml.

Here is the picture of my directory structure

I can even have the main class locate and print out the files' paths using rootBundle, but trying to initialize a new File using those paths provides the same error text. If I were to use path provider to locate and read from files, how would I initially put the files into the Temporary Directory or Application Documents Directory, if Flutter does not recognize the file paths of the files that I want to insert?


Solution

  • Just You need to remove folder name ''.

    assets\importfiles 
    

    enter image description here

    to

    assets Or importfiles
    

    enter image description here

    Thanks You.Happy To help you