findFor method
Implementation
EmbeddingTokenizerProvider? findFor(EmbeddingModelSpec spec) {
final matches = _registered.where((p) => p.canHandle(spec)).toList();
if (matches.isEmpty) return null;
final indexed = [for (var i = 0; i < matches.length; i++) (i, matches[i])];
indexed.sort((a, b) {
final byPriority = b.$2.priority.compareTo(a.$2.priority);
return byPriority != 0 ? byPriority : a.$1.compareTo(b.$1);
});
if (kDebugMode &&
indexed.length > 1 &&
indexed[0].$2.priority == indexed[1].$2.priority) {
edgeAiLog(
'[flutter_edge_ai] Ambiguous embedding tokenizer: '
'${indexed.map((e) => e.$2.name).join(", ")} all handle this spec at '
'priority ${indexed[0].$2.priority}; using "${indexed[0].$2.name}".',
);
}
return indexed.first.$2;
}