isNumeric property

bool isNumeric

Determines whether the string consists solely of numeric characters (0-9). This can be used to validate if a string represents a valid integer.

Example:

print('1234'.isNumeric); // Output: true
print('12a4'.isNumeric); // Output: false

Implementation

bool get isNumeric => RegExp(r'^\d+$').hasMatch(this);