isCharDigit function
Returns true
if char
represents a digit, false
otherwise.
This function checks whether the input string is not empty and whether its first character is a digit (i.e., has a Unicode code point between the code points of '0' and '9').
If the input string satisfies this condition, the function returns true
.
Otherwise, it returns false
.
Implementation
bool isCharDigit(String char) {
if (char.isEmpty) return false;
final firstCodePoint = char.codeUnitAt(0);
return (firstCodePoint >= '0'.codeUnitAt(0)) &&
(firstCodePoint <= '9'.codeUnitAt(0));
}