lan_scanner 2.0.1
lan_scanner: ^2.0.1 copied to clipboard

A package that allows discovering network devices via UDP or ICMP pings.

lan_scanner #

Pub badge style: lint

Dart / Flutter package that allows discovering network devices in local network (LAN).

Note: This library is intended to be used on Class C networks.

This project is a rework of already existing ping_discover_network, which is no longer maintained.

pub.dev page | API reference

Getting Started #

Add the package to your pubspec.yaml:

lan_scanner: ^2.0.1

Import the library:

import 'package:lan_scanner/lan_scanner.dart';

Create an instance of the class and call quickScan() or preciseScan() on it:

final port = 80;
final subnet = "192.168.0";
final timeout = Duration(seconds: 5);

final scanner = LanScanner();

final stream = scanner.preciseScan(
    subnet,
    timeout: timeout,
    progressCallback: (ProgressModel progress) {
        print('${progress.percent * 100}% 192.168.0.${progress.currIP}');
    },
);

stream.listen((DeviceModel device) {
    if (device.exists) {
        print("Found device on ${device.ip}:${device.port}");
    }
});

If you don't know what is your subnet, you can use network_info_plus and then ipToSubnet() function.

var wifiIP = await (NetworkInfo().getWifiIP())

var subnet = ipToSubnet(wifiIP);

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Open in Visual Studio Code

20
likes
120
pub points
69%
popularity

Publisher

hubertjozwiak.codes

A package that allows discovering network devices via UDP or ICMP pings.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_icmp_ping

More

Packages that depend on lan_scanner