restoreCache static method
Restores a previously saved offset (e.g. from SharedPreferences or
secure storage) to enable offline-first accuracy on application startup.
Implementation
static void restoreCache({
required Duration offset,
DateTime? syncTime,
}) {
final nowLocal = DateTime.now();
_cachedOffset = offset;
_lastSyncTime = syncTime ?? nowLocal;
_lastSyncElapsed = _stopwatch.elapsed;
_lastSyncDetails = NtpResponse(
dateTime: nowLocal.add(offset),
offset: offset,
roundTripDelay: Duration.zero,
server: 'cache',
referenceId: 'CACH',
);
}