dynKeepAlphanumeric function

String dynKeepAlphanumeric(
  1. String value
)

Keeps ASCII letters and digits only.

Implementation

String dynKeepAlphanumeric(String value) {
  final kept = StringBuffer();
  for (var index = 0; index < value.length; index++) {
    final unit = value.codeUnitAt(index);
    final isDigit = unit >= 0x30 && unit <= 0x39;
    final isUpper = unit >= 0x41 && unit <= 0x5a;
    final isLower = unit >= 0x61 && unit <= 0x7a;
    if (isDigit || isUpper || isLower) kept.writeCharCode(unit);
  }
  return kept.toString();
}