isDigit property

bool get isDigit

Check whether a string is digit or not

'123'.isDigit(); // false
'123.456'.isDigit(); // false
'abc'.isDigit(); // false
'123abc'.isDigit(); // false

Implementation

bool get isDigit {
  final isMatch = RegExp(r'\d').hasMatch(this);
  return isMatch && length == 1;
}