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.

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_ntp/flutter_ntp.dart';

void main() {
  runApp(const ExampleWidget());
}

class ExampleWidget extends StatelessWidget {
  const ExampleWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('NTP Example')),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              try {
                DateTime currentTime = await FlutterNTP.now();
                log('Current NTP time: $currentTime');
              } catch (e) {
                log('Error fetching NTP time: $e');
              }
            },
            child: const Text('Fetch NTP Time'),
          ),
        ),
      ),
    );
  }
}
4
likes
160
pub points
56%
popularity

Publisher

unverified uploader

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