ntp_dart 1.3.0
ntp_dart: ^1.3.0 copied to clipboard
A lightweight, cross-platform NTP client for Dart & Flutter. Fetches highly accurate time via native UDP and Web HTTP fallbacks with microsecond precision and secure caching.
Changelog #
1.3.0 #
- Refactored Cache: Transitioned
AccurateTimecache to use time offset calculation (cachedOffset) rather than absolute datetime tracking, boosting reliability and simplifying local drift corrections. - Microsecond Precision: Enhanced UDP packet timestamp parsing and math to support full microsecond accuracy (matching Dart's
DateTimeresolution). - Socket and Stream Safety: Rewrote UDP networking in
ntp_io.dartwith robusttry-finallyblocks to guarantee socket closure and prevent resource leakages on bad networks or cancellation. - RFC 5905 Security Compliance: Implemented transmit timestamp writing and randomized low-order bits on client request packets to resist off-path spoofing and replay attacks.
- NtpServer Enum: Introduced
NtpServerenum offering curated, ultra-reliable servers (google,cloudflare,apple,microsoft,nist,pool). - Flexible Fallbacks: Added
allowFallbackandforceRefreshtoAccurateTime.now(). - Test Suite: Introduced a comprehensive unit testing framework in
test/ntp_dart_test.dart.
1.2.1 #
- Added
isUtcparameter (defaultfalse) toAccurateTime.now(),AccurateTime.nowSync(), andAccurateTime.nowToIsoString(). - Fixed caching logic in
AccurateTimeto always store UTC and convert to local only when requested.
1.2.0 #
- Added
apiUrlandparseResponseparameters toNtpBaseto allow custom API endpoints and response parsing on Web. - Added
isUtcparameter (defaultfalse) to control whether to return UTC or Local time. - Implemented latency compensation for both Web and IO.
- Improved NTP timestamp parsing in IO to support millisecond precision.
- Added timeout support for Web NTP requests.
- Updated dependencies:
httpto ^1.6.0 andintlto ^0.20.2.
1.1.1 #
- Added
AccurateTime.nowSync()method to provide a synchronous time value, useful for UI rendering while the first sync is in progress. - Change logic for conditional import based on platform. No breaking API changes.
- Updated
httpdependency (previously 1.4.0) to 1.5.0. - Refreshed README and examples to reflect the new platform setup and usage notes.
1.0.2 #
- Update documentation
1.0.1 #
- Enable flutter web wasm compatibility
1.0.0 #
- Publish package