I am making a dropdown button in flutter. Its content depends on how many files there is in a folder. For example, I have the following assets folder assets/logos/. This folder has 4 files. Another folder could be assets/monsters/. This folder has 3 files. The first folder would result in a dropdown with the values 1,2,3, and 4. I have made the following method:
Directory monsterDirectory = new Directory(await rootBundle.loadString(path));
List skins = monsterDirectory.listSync();
skins.forEach((skin) {
skinNumber++;
amountOfSkins.add(skinNumber.toString());
skinNumber++;
});
Where path
is the assets path 'assets/collectibles/monsters/astro/'
.
This gives the following error:
Directory listing failed, path = 'assets/collectibles/monsters/astro/' (OS Error: No such file or directory, errno = 2)
What am I doing wrong?