initializeDatabase method

Future<void> initializeDatabase()

شرح: تهيئة قاعدة البيانات فقط إذا تغير الاسم Explanation: Only initialize DB if name changed

Implementation

Future<void> initializeDatabase() async {
  String dbName = tafsirAndTranslateNames[radioValue.value].databaseName;
  if (database.value == null || currentDbFileName != dbName) {
    await database.value?.close();
    database.value = TafsirDatabase(dbName);
    currentDbFileName = dbName;
    log('Database object created.', name: 'TafsirCtrl');
  }
  log('Database initialized.', name: 'TafsirCtrl');
}