isPerfectSquare method

bool isPerfectSquare()

Checks if this integer is a perfect square.

Implementation

bool isPerfectSquare() {
  if (this < 0) return false;
  final root = math.sqrt(this).toInt();
  return root * root == this;
}