Reputation: 113
I checked for typos. I have the file in pubspec.yaml assets section. I cannot understand why it can't find the file which is not empty.
Error message:
Performing hot restart... Waiting for connection from debug service on Chrome... Restarted application in 337ms. Error while trying to load an asset: Flutter Web engine failed to fetch >"assets/assets/rungFile.txt". HTTP request succeeded, but the server responded with HTTP >status 404. Error: Unable to load asset: "assets/rungFile.txt". The asset does not exist or has empty data.
void readFile() async {
String data = await rootBundle.loadString('assets/rungFile.txt');
List<String> lines = const LineSplitter().convert(data);
for (String line in lines) {
List<String> words = line.split(',');
Rung rung = Rung(name: words[0], rungId: words[1], done: bool.parse(words[2]),
boldTitle: bool.parse(words[3]), info: words[4]);
Rung.myList.add(rung);
}
}
Upvotes: 0
Views: 160