foldKey method

String foldKey(
  1. String input
)

Applies the active case-folding strategy to input.

  • When caseSensitive is true, returns input unchanged.
  • When caseSensitive is false and caseFold is provided, uses that callback. The callback is wrapped — if it throws, this method falls back to input.toLowerCase() so a buggy folder cannot break translation lookups.
  • Otherwise, returns input.toLowerCase().

Implementation

String foldKey(String input) {
  if (caseSensitive) return input;
  final fold = caseFold;
  if (fold != null) {
    try {
      return fold(input);
    } catch (_) {
      // Defensive fallback. A safety-critical host should install
      // [TranslationManager.onError] to be notified of this path.
      return input.toLowerCase();
    }
  }
  return input.toLowerCase();
}