Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// It's necessary to pass correct path to be able to use this library.final appDocDirectory = awaitgetApplicationDocumentsDirectory();
awaitconfigureNetworkTools(appDocDirectory.path, enableDebugging: true);
runApp(constMyApp());
}
Usage
Host Scanner
String address = '192.168.1.12';
// or You can also get address using network_info_plus package// final String? address = await (NetworkInfo().getWifiIP());finalString subnet = address.substring(0, address.lastIndexOf('.'));
final stream = HostScannerService.instance.getAllPingableDevices(subnet, firstHostId: 1, lastHostId: 50,
progressCallback: (progress) {
print('Progress for host discovery : $progress');
});
stream.listen((host) {
//Same host can be emitted multiple times//Use Set<ActiveHost> instead of List<ActiveHost>print('Found device: $host');
}, onDone: () {
print('Scan completed');
}); // Don't forget to cancel the stream when not in use.