isDigit static method

bool isDigit(
  1. String s
)

Checks if the given string s is a digit.

Will return false if the given string s is empty.

Implementation

static bool isDigit(String s) {
  if (s.isEmpty) {
    return false;
  }
  if (s.length > 1) {
    for (var r in s.runes) {
      if (r ^ 0x30 > 9) {
        return false;
      }
    }
    return true;
  } else {
    return s.runes.first ^ 0x30 <= 9;
  }
}