validate method

void validate()

Implementation

void validate() {
  if (!latitude.isFinite || latitude < -90 || latitude > 90) {
    throw const FormatException(
      'Location latitude must be finite and between -90 and 90.',
    );
  }
  if (!longitude.isFinite || longitude < -180 || longitude > 180) {
    throw const FormatException(
      'Location longitude must be finite and between -180 and 180.',
    );
  }
  if (!accuracyMeters.isFinite || accuracyMeters < 0) {
    throw const FormatException(
      'Location accuracyMeters must be finite and non-negative.',
    );
  }
  if (!capturedAtUtc.isUtc) {
    throw const FormatException('Location capturedAtUtc must be UTC.');
  }
  if (source != deviceSource) {
    throw const FormatException('Location source must be "device".');
  }
}