populateDictionaryFormats method

void populateDictionaryFormats()

Populate maps for dictionary formats at startup to optimise performance.

Implementation

void populateDictionaryFormats() async {
  /// A list of dictionary formats that the app will support at runtime.
  final List<DictionaryFormat> availableDictionaryFormats =
      List<DictionaryFormat>.unmodifiable(
    [
      YomichanFormat.instance,
      MigakuFormat.instance,
      AbbyyLingvoFormat.instance,
    ],
  );

  dictionaryFormats = Map<String, DictionaryFormat>.unmodifiable(
    Map<String, DictionaryFormat>.fromEntries(
      availableDictionaryFormats.map(
        (dictionaryFormat) => MapEntry(
          dictionaryFormat.uniqueKey,
          dictionaryFormat,
        ),
      ),
    ),
  );
}