assertPerfectSquare method

void assertPerfectSquare({
  1. String? message,
})

Asserts that this number is a perfect square.

A perfect square is an integer that is the square of another integer.

Throws a test failure if this number is not a perfect square.

  • message: Optional custom message for the failure reason.

Implementation

void assertPerfectSquare({String? message}) {
  expect(sqrt(this) % 1 == 0, isTrue,
      reason: message ?? 'Expected $this to be a perfect square');
}