isNumber property

bool get isNumber

Check whether a string is a number or not

'123'.isNumber(); // true
'123.456'.isNumber(); // true
'abc'.isNumber(); // false
'123abc'.isNumber(); // false

Implementation

bool get isNumber {
  final isMatch = RegExp("[0-9]").hasMatch(this);
  return isMatch;
}