tryInvert method Null safety

Matrix4? tryInvert(
  1. Matrix4 other
)

Returns a matrix that is the inverse of other if other is invertible, otherwise null.

Implementation

static Matrix4? tryInvert(Matrix4 other) {
  final r = Matrix4.zero();
  final determinant = r.copyInverse(other);
  if (determinant == 0.0) {
    return null;
  }
  return r;
}