flutter_ntp

Last updated:

0 purchases

flutter_ntp Image
flutter_ntp Images
Add to Cart

Description:

flutter ntp

flutter_ntp #

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
copied to clipboard
Install packages from the command line:
flutter pub get
copied to clipboard
Usage #
Import the package where needed:
import 'package:flutter_ntp/flutter_ntp.dart';
copied to clipboard
Fetching NTP Time #
DateTime currentTime = await FlutterNTP.now();
print('Current NTP time: $currentTime');
copied to clipboard
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),
);
copied to clipboard
Support #
If you find this plugin helpful, consider supporting me:

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.