isPerfectCube method

bool isPerfectCube()

Checks if this integer is a perfect cube.

Implementation

bool isPerfectCube() {
  final n = abs();
  var cubeRoot = 0;
  while (cubeRoot * cubeRoot * cubeRoot < n) {
    cubeRoot++;
  }
  return cubeRoot * cubeRoot * cubeRoot == n;
}