tafsirDownload method
Implementation
Future<void> tafsirDownload(int i) async {
Directory databasePath = await getApplicationDocumentsDirectory();
String path;
String fileUrl;
if (isTafsir.value) {
path = join(databasePath.path, tafsirDBName[i]);
fileUrl =
'https://github.com/alheekmahlib/Islamic_database/raw/refs/heads/main/tafseer_database/${tafsirDBName[i]}';
} else {
path = join(databasePath.path, '${tafsirName[i]['bookName']}.json');
fileUrl =
'https://github.com/alheekmahlib/Islamic_database/raw/refs/heads/main/quran_database/translate/${tafsirName[i]['bookName']}.json';
}
if (!onDownloading.value) {
await downloadFile(path, fileUrl).then((_) async {
onDownloadSuccess(tafsirName[i]['name']);
saveTafsirDownloadIndex(tafsirName[i]['name']);
loadTafsirDownloadIndices();
if (isTafsir.value) {
await fetchData(QuranCtrl.instance.state.currentPageNumber.value + 1);
} else {
await handleRadioValueChanged(i);
await fetchTranslate();
}
});
log("Downloading from URL: $fileUrl");
}
}