I am trying to populate a Hive box in my Flutter app. I'm populating it with some quest objects, and then each quest has a HiveList of clues objects
Box<Quest> quests = await initQuests();
List<Clue> clues = await initClues();
for (var i = 0; i < quests.length; i++) {
Quest cQuest = quests.getAt(i);
Iterable<Clue> questClues = clues.where((cClue) => cClue.associatedQuest == cQuest.id);
Box<Clue> questCluesBox = await Hive.openBox<Clue>('quest_${cQuest.id}_clues');
questCluesBox.addAll(questClues);
quests.getAt(i).clues = HiveList(questCluesBox);
cQuest.save();
}
When I run the code I get the following error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: RangeError (index): Index out of range: no indices are valid: 0
I'm assigning a variable, not trying to access an element in an array, so I don't know what the error means.
Any ideas?