mask method

String mask(
  1. String input
)

Masks the provided input using the strategy configuration.

Implementation

String mask(String input) {
  if (input.isEmpty) return '';
  final total = input.length;
  final visible = keepStart + keepEnd;
  final maskedCount = (total - visible).clamp(minMasked, total);
  if (maskedCount <= 0) return maskChar * total;
  final start = input.substring(0, keepStart.clamp(0, total));
  final end = input.substring(total - keepEnd.clamp(0, total));
  return '$start${maskChar * maskedCount}$end';
}