NtpClient class

A socket-based implementation of an NTP (Network Time Protocol) client.

This implementation communicates directly with an NTP server over UDP to retrieve the current UTC time. It is intended for platforms where raw sockets are available (e.g., mobile or desktop) and cannot be used in browser environments.

By default, it queries the public NTP pool (pool.ntp.org) on port 123, but the server, port, and timeout parameters can be customized via the constructor.

Inheritance

Constructors

NtpClient.new({String server = 'pool.ntp.org', int port = 123, int timeout = 5})
Creates a new NtpClient instance with optional configuration parameters.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
port int
The UDP port used to communicate with the NTP server.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
server String
The hostname or IP address of the NTP server to query.
finalinherited
timeout int
The timeout in seconds for the time retrieval operation.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
now() Future<DateTime>
Retrieves the current UTC DateTime from the configured NTP server.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited