pub package


Plugin that allows you to get precise time from Network Time Protocol (NTP). Whole NTP protocol is implemented in dart.

By default lookup address for NTP is:

How it works

Using int offset from getNtpTime()

  • default localTime is
  • default lookUpAddress is ''
  • default port is 123
  DateTime startDate = new DateTime().now().toLocal();
  int offset = await NTP.getNtpTime(localTime: startDate);
  print('NTP DateTime offset align: ${startDate.add(new Duration(milliseconds: offset))}');

Using DateTime from now

  DateTime startDate = await;
  print('NTP DateTime: ${startDate}');

NTP Functions

  Future<int> getNtpTime({
    String lookUpAddress: '',
    int port: 123,
    DateTime localTime,
  Future<DateTime> now();