decoderForFormatId method

PixaDecoderDescriptor? decoderForFormatId(
  1. String formatId
)

Returns the highest-priority decoder descriptor for formatId, if any.

Implementation

PixaDecoderDescriptor? decoderForFormatId(String formatId) {
  final String normalized = _normalizeRouteClaim(formatId);
  if (normalized.isEmpty) {
    return null;
  }
  PixaDecoderDescriptor? selected;
  for (final PixaDecoderDescriptor decoder in _decoders.values) {
    final bool handlesFormat = decoder.formatIds
        .map(_normalizeRouteClaim)
        .any((String candidate) => candidate == normalized);
    if (!handlesFormat) {
      continue;
    }
    if (selected == null || decoder.priority > selected.priority) {
      selected = decoder;
    }
  }
  return selected;
}