openDB static method

Future<void> openDB({
  1. void onInitializeHive()?,
})

Implementation

static Future<void> openDB({void Function()? onInitializeHive}) async {
  if (onInitializeHive == null) {
    await Hive.initFlutter();
    if (!Hive.isAdapterRegistered(DOO_CONTACT_HIVE_TYPE_ID)) {
      Hive..registerAdapter(DOOContactAdapter());
    }
    if (!Hive.isAdapterRegistered(DOO_CONVERSATION_HIVE_TYPE_ID)) {
      Hive..registerAdapter(DOOConversationAdapter());
    }
    if (!Hive.isAdapterRegistered(DOO_MESSAGE_HIVE_TYPE_ID)) {
      Hive..registerAdapter(DOOMessageAdapter());
    }
    if (!Hive.isAdapterRegistered(DOO_EVENT_USER_HIVE_TYPE_ID)) {
      Hive..registerAdapter(DOOEventMessageUserAdapter());
    }
    if (!Hive.isAdapterRegistered(DOO_USER_HIVE_TYPE_ID)) {
      Hive..registerAdapter(DOOUserAdapter());
    }
  } else {
    onInitializeHive();
  }

  await PersistedDOOContactDao.openDB();
  await PersistedDOOConversationDao.openDB();
  await PersistedDOOMessagesDao.openDB();
  await PersistedDOOUserDao.openDB();
}