'Flutter Dart OS Error: No such file or directory, errno = 2
I'm new to flutter and got a quick question:
I am trying to create a List of all elements located within a directory called "importfiles", which is located in a directory called "assets" in the same directory as "lib" and "build". However, when creating a new Directory instance, the error "OS Error: No such file or directory, errno = 2" is thrown.
I currently have the initialization of a Directory instance using the file path string, and a small for loop to count the number of items in the directory.
The code I am trying to run is as follows:
import 'dart:io';
Directory gpxLocation = new Directory('assets/importfiles');
List elementList = gpxLocation.listSync();
for (int i = 0; i < elementList.length; i++) {
if (elementList[i] is File) {
print(i);
//gpxList.add(elementList[i]);
}
}
I have tried all sorts of Strings to represent the file path. Forwards slashes,backwards slashes, escape characters, and even including the entire fle path as seen in file explorer. Adding "assets/importfiles/" to pubsec.yaml has not worked either.
Any thoughts?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
