isPerfectSquare static method

bool isPerfectSquare(
  1. int n
)

Checks if a number n is a perfect square.

Implementation

static bool isPerfectSquare(int n) {
  final sqrtN = math.sqrt(n).toInt();
  return sqrtN * sqrtN == n;
}