isDigit function

bool isDigit(
  1. String char
)

Checks whether the given string is a digit from 0 to 9.

This function takes a String and returns true if the string represents a digit from 0 to 9, and false otherwise.

Implementation

bool isDigit(final String char) {
  const List<String> digits = [
    '0',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
  ];
  return digits.contains(char);
}