toNumeric static method
Converts a string to contain only numeric characters.
Example: 'abc123!@#' -> '123'
Implementation
static String toNumeric(String? value, [bool onlyDigit = false]) {
String buffer = '';
if (value != null) {
for (String character in value.characters) {
if (onlyDigit
? Validator.isDigit(character)
: Validator.isNumeric(character)) {
buffer = '$buffer$character';
}
}
}
return buffer;
}