isZero method

bool isZero()

Returns true if this is a zero vector, i.e., all its elements are zero.

Example:

var v = Vector.fromList([0, 0, 0]);
print(v.isZero());

Output:

true

Implementation

bool isZero() {
  for (var i = 0; i < length; i++) {
    if (this[i] != 0) {
      return false;
    }
  }
  return true;
}