absoluteError function Null safety

double absoluteError (
  1. dynamic calculated,
  2. dynamic correct
)

Returns absolute error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.

Implementation

double absoluteError(dynamic calculated, dynamic correct) {
  if (calculated is num && correct is num) {
    final diff = (calculated - correct).abs().toDouble();
    return diff;
  }
  // ignore: return_of_invalid_type
  return calculated.absoluteError(correct);
}