Home > Net >  Flutter can't find txt file
Flutter can't find txt file

Time:04-14

I'm trying to use the pubspec.yaml screenshot

Here is my file structure to show that the file is actually there:

File Structure

What's the problem with the code? Why it can't find the file?

CodePudding user response:

You can change your pubspec file to only:

Assets/

And then call:

File file = File("Facts/English.txt");

CodePudding user response:

Rename your Asset directory to assets (small case). because as per the flutter official document (name libraries, packages, directories, and source files using lowercase_with_underscores.fileextension)check this link for reference.

so in your case do following things:

1. Rename your Asset directory to assets 
2. Rename subdirectories to audio, facts
3. also rename file to english.txt 

use string file path like thin 'assets/facts/english.txt'

  • Related