slugClickName function

String slugClickName(
  1. String? text
)

Human text to a name stem: lowercased, accents stripped, punctuation collapsed, words with a digit and currency words dropped, first four words, joined with _. "Pay ₹5,000 now" → pay_now, "Cart (3)" → cart. Empty for text that identifiesSomeone.

Implementation

String slugClickName(String? text) {
  if (text == null || text.trim().isEmpty) return '';
  final head = text.length > kClickNameMaxTextChars
      ? text.substring(0, kClickNameMaxTextChars)
      : text;
  if (identifiesSomeone(head)) return '';
  return normaliseClickText(head)
      .split(' ')
      .where((w) =>
          w.isNotEmpty &&
          !w.codeUnits.any((c) => c >= 0x30 && c <= 0x39) &&
          !_kCurrencyWords.contains(w))
      .take(_kMaxNameWords)
      .join('_');
}