populateMediaTypes method

void populateMediaTypes()

Populate maps for media types at startup to optimise performance.

Implementation

void populateMediaTypes() async {
  /// A list of media types that the app will support at runtime.
  final List<MediaType> availableMediaTypes = List<MediaType>.unmodifiable(
    [
      PlayerMediaType.instance,
      ReaderMediaType.instance,
      DictionaryMediaType.instance,
    ],
  );

  mediaTypes = Map<String, MediaType>.unmodifiable(
    Map<String, MediaType>.fromEntries(
      availableMediaTypes.map(
        (mediaType) => MapEntry(mediaType.uniqueKey, mediaType),
      ),
    ),
  );
}