init method
Initialize. Safe to call multiple times (no-op after first).
Implementation
Future<void> init() async {
if (_initialized) return;
_surahs = await QuranDataLoader.loadSurahs();
_store = await QuranDataLoader.load();
for (final entry in _store!.linesByPage.entries) {
final page = entry.key;
for (final line in entry.value) {
if (line.surahNumber != null && line.surahNumber! > 0) {
_pageSurahMap.putIfAbsent(page, () => line.surahNumber!);
}
}
if (!_pageSurahMap.containsKey(page)) {
for (final line in entry.value) {
if (line.firstWordId != null) {
final word = _store!.wordsById[line.firstWordId];
if (word != null) {
_pageSurahMap.putIfAbsent(page, () => word.surah);
break;
}
}
}
}
}
_initialized = true;
}