isInt property

bool get isInt

Checks if the string represents a valid integer.

This method attempts to convert the string to an integer and checks if the conversion is successful.

Example:

var numStr = '123';
var invalidStr = 'abc';
print(numStr.isInt); // Outputs: true
print(invalidStr.isInt); // Outputs: false

Returns true if the string can be parsed as an integer, otherwise false.

Implementation

bool get isInt {
  return toInt(def: -99999999) != -99999999;
}