Skip to content
pubscout

ntp

2.0.0, released 6 years ago by square-pear.com

Fetch accurate current time from an NTP server as a DateTime object.

$ flutter pub add ntp
Source repository

What it does

The package implements the NTP protocol in pure Dart and provides functions to obtain the clock offset or a corrected DateTime. It works on all major platforms without native code.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Device clock may be tampered or inaccurate
  • You need a reliable timestamp for time‑based events
  • Simple NTP sync without adding heavy networking libraries

Skip it when

  • High‑frequency or sub‑second synchronization is required
  • You need full NTP client features like multiple servers or authentication
  • Timezone or locale‑aware date handling is needed

Strengths

  • Pure Dart implementation works everywhere
  • Null‑safe and lightweight
  • Easy to use API

Weaknesses

  • Only a single default NTP server (time.google.com)
  • No built‑in caching or advanced NTP features
  • No automatic retry or fallback logic

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:ntp/ntp.dart';

void main() async {
  DateTime now = await NTP.now();
  print('NTP time: $now');
}

Alternatives

Packages that do the same job and could replace ntp.

  • timezone

    Time zone databases and time zone aware DateTime class in Dart.

  • ntp_dart

    Cross-platform NTP and SNTP time synchronization client for Dart and Flutter.

  • flutter_ntp

    A small, fast NTP client for Flutter and Dart with built-in offset caching.

  • dart_date

    Date manipulation library providing DateTime extensions and an Interval object.

Works with

Packages commonly used together with ntp: ones it builds on, ones built on it, and its own family.