lan_scanner
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, however it is no longer maintained.
getting started
add the package to your pubspec.yaml:
lan_scanner: ^2.0.0
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.
Comments are closed.