ntp 1.0.0

  • Readme
  • Changelog
  • Installing
  • 82

pub package

ntp #

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: pool.ntp.org

How it works #

Using int offset from getNtpTime()

  • default localTime is DateTime.now()
  • default lookUpAddress is 'pool.ntp.org'
  • 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 NTP.now();
  print('NTP DateTime: ${startDate}');

NTP Functions #

  Future<int> getNtpTime({
    String lookUpAddress: 'pool.ntp.org',
    int port: 123,
    DateTime localTime,
  });
  Future<DateTime> now();

[1.0.0] - 18.07.2018.

  • Methods in NTP are now static.

  • Added now() for returning current DateTime object with calculated NTP offset

  • getNtpTime was renamed to getNtpOffset (since it is returning int offset in milliseconds)

[0.0.1] - 16.04.2018.

  • Get NTP clock offset

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ntp: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ntp/ntp.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
88
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
39
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/ntp/ntp.dart.

Run flutter format to format lib/ntp/ntp.dart.

Format lib/ntp/ntp_message.dart.

Run flutter format to format lib/ntp/ntp_message.dart.

Maintenance suggestions

Package is getting outdated. (-30.68 points)

The package was last published 68 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and ntp.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test