setTargetSurah method
Sets the actively tracked surah, reloading its phoneme reference.
By default every other surah's tracked highlights are wiped too (the
pre-existing behavior — appropriate for starting a fresh, unrelated
session). Pass preserveOtherSurahStates: true when retargeting
mid-session across a surah boundary (a verse group spanning two
surahs, a continuous reading view, …) so the surah being left keeps
its already-committed highlights — read them back afterwards with
isWordGreen etc. and an explicit surah: argument, or
completedAyahsFor. Set clearTargetSurah to false when navigating back
to an already-tracked surah and its existing highlights should be retained.
Implementation
Future<void> setTargetSurah(
int surah, {
bool preserveOtherSurahStates = false,
bool clearTargetSurah = true,
}) async {
_targetSurah = surah;
_currentMatch = null;
activeAyah.value = null;
_highlights.clearForRetarget(
surah,
preserveOtherSurahs: preserveOtherSurahStates,
clearTargetSurah: clearTargetSurah,
);
globalRevision.value++;
notifyListeners();
await repository.loadSurahAsync(surah);
_currentSurahWords = repository.getSurahWords(surah);
reset();
}