I am trying to read a csv
file in flutter and I am getting an error
(OS Error: No such file or directory, errno = 2)
The csv file has been declared in assets section in pubspec.yaml
And the path to the file is correct, here is my attempt to read the file synchronously:
-- at the begining of the class:
List<String> lines;
-- pubspec.yaml, assets section:
assets:
- assets/videos/
- assets/images/
- assets/data/data.csv
-- Method to read file
void _readDataFile(String csvFile) {
File file = File(csvFile);
lines = file.readAsLinesSync();
}
-- Calling the above method ---
@override
void initState() {
super.initState();
//other stuff ...
// ...
// ...
_readDataFile("assets/data/data.csv");
}