toggleDictionaryCollapsed method

void toggleDictionaryCollapsed(
  1. Dictionary dictionary
)

Toggle a dictionary's between collapsed and expanded state. This will affect how a dictionary's search results are shown by default.

Implementation

void toggleDictionaryCollapsed(Dictionary dictionary) {
  _database.writeTxnSync(() {
    if (dictionary.isCollapsed(targetLanguage)) {
      dictionary.collapsedLanguages = [...dictionary.collapsedLanguages]
        ..remove(targetLanguage.languageCode);
    } else {
      dictionary.collapsedLanguages = [
        ...dictionary.collapsedLanguages,
        targetLanguage.languageCode
      ];
    }
    _database.dictionarys.putSync(dictionary);
  });
}