flutter_icmp_ping 3.1.3 copy "flutter_icmp_ping: ^3.1.3" to clipboard
flutter_icmp_ping: ^3.1.3 copied to clipboard

Flutter plugin that sends ICMP ECHO_REQUEST to network hosts.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Ping? ping;

    void startPing() async {
      try {
        ping = Ping(
          'google.com',
          count: 3,
          timeout: 1,
          interval: 1,
          ipv6: false,
          ttl: 40,
        );
        ping!.stream.listen((event) {
          debugPrint(event.toString());
        });
      } catch (e) {
        debugPrint('error $e');
      }
    }

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Ping example app'),
        ),
        body: Center(
          child: Column(
            children: [
              TextButton(
                child: const Text('start'),
                onPressed: startPing,
              ),
              TextButton(
                child: const Text('stop'),
                onPressed: () {
                  ping?.stop();
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
14
likes
160
points
16.6k
downloads

Publisher

verified publisherzuvola.com

Weekly Downloads

Flutter plugin that sends ICMP ECHO_REQUEST to network hosts.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

async, flutter

More

Packages that depend on flutter_icmp_ping