validate method
Checks client-side constraints without making a network call.
Implementation
void validate({required DateTime now}) {
if (!latitude.isFinite || latitude < -90 || latitude > 90) {
throw ArgumentError('latitude must be between -90 and 90.');
}
if (!longitude.isFinite || longitude < -180 || longitude > 180) {
throw ArgumentError('longitude must be between -180 and 180.');
}
final accuracy = accuracyMeters;
if (accuracy != null && (!accuracy.isFinite || accuracy < 0)) {
throw ArgumentError('accuracyMeters must be non-negative.');
}
if (occurredAt.isAfter(now.toUtc().add(const Duration(minutes: 5)))) {
throw ArgumentError(
'occurredAt cannot be more than 5 minutes in the future.',
);
}
}