checkMaxDigit static method

bool checkMaxDigit(
  1. String string,
  2. int maxDigit
)

Implementation

static bool checkMaxDigit(String string, int maxDigit) {
  int counter = 0;

  for (int i = 0; i < string.length; i++) {
    if (string.codeUnitAt(i) >= 0 && string.codeUnitAt(i) <= 9) {
      counter++;
    }
  }
  if (counter <= maxDigit) {
    return true;
  }
  return false;
}