flutter_ntp 0.0.2 copy "flutter_ntp: ^0.0.2" to clipboard
flutter_ntp: ^0.0.2 copied to clipboard

A flutter implementation of (NTP) Network Time Protocol server.

flutter_ntp #

pub package

A Flutter package for obtaining accurate time using Network Time Protocol (NTP).

Overview #

flutter_ntp is a Dart package designed to fetch accurate time information using NTP servers. It supports querying various NTP servers and caching responses to improve performance and reliability.

Features #

  • NTP Querying: Fetch accurate time from NTP servers.
  • Server Flexibility: Supports querying from a wide range of NTP servers.
  • Caching: Optionally caches NTP responses to reduce network calls and improve performance.
  • Timeout Handling: Configurable timeout for NTP queries.
  • Easy Integration: Simple API for fetching NTP time in your Flutter applications.

Installation #

Add flutter_ntp to your pubspec.yaml file:

dependencies:
  flutter_ntp: ^version

Install packages from the command line:

flutter pub get

Usage #

Import the package where needed:

import 'package:flutter_ntp/flutter_ntp.dart';

Fetching NTP Time #

 DateTime currentTime = await FlutterNTP.now();
 print('Current NTP time: $currentTime');

Parameters #

  • lookUpAddress: Optional. The NTP server address to query. Default is google, you can access NtpServer and change the address.
  • port: Optional. The port number for NTP query. Default is 123, which uses default port for google server.
  • timeout: Optional. Timeout duration for NTP query. Default is null.
  • cacheDuration: Optional. Duration to cache NTP responses. Default is 1 hour.

Example #

DateTime currentTime = await NTP.now(
  lookUpAddress: NtpServer.google.url,
  port: 123,
  timeout: Duration(seconds: 5),
  cacheDuration: Duration(minutes: 30),
);

Support #

If you find this plugin helpful, consider supporting me:

Buy Me A Coffee

5
likes
160
points
66
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter implementation of (NTP) Network Time Protocol server.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_ntp