pow method Null safety

Complex pow(
  1. Complex exp
)

Compute this^exp

Implementation

Complex pow(Complex exp) {
  // y^x = e^(x ln y)
  final x = exp;
  final y = this;
  final yR = y.r;
  if (yR == 0) {
    if (x == Complex.zero) {
      throw CalculatorError(0);
    }
    return Complex.zero;
  } else {
    final lnY = Complex(dart.log(yR), y.theta);
    final xLnY = x * lnY;
    final resultR = dart.exp(xLnY.real);
    return Complex(resultR * dart.cos(xLnY.imaginary),
        resultR * dart.sin(xLnY.imaginary));
  }
}