network_tools_flutter 1.0.1 copy "network_tools_flutter: ^1.0.1" to clipboard
network_tools_flutter: ^1.0.1 copied to clipboard

Extended features of network_tools package for flutter framework supporting iOS and Android

example/main.dart

import 'package:logging/logging.dart';
import 'package:network_tools/network_tools.dart';
import 'package:network_tools_flutter/network_tools_flutter.dart';

void main() {
  // Logger.root.level = Level.FINE;
  // Logger.root.onRecord.listen((record) {
  //   print(
  //     '${DateFormat.Hms().format(record.time)}: ${record.level.name}: ${record.loggerName}: ${record.message}',
  //   );
  // });
  final log = Logger("host_scan_example");

  const String address = '192.168.1.1';
  // or You can also get address using network_info_plus package
  // final String? address = await (NetworkInfo().getWifiIP());
  final String subnet = address.substring(0, address.lastIndexOf('.'));

  // You can set [firstHostId] and scan will start from this host in the network.
  // Similarly set [lastHostId] and scan will end at this host in the network.
  final stream = HostScannerFlutter.getAllPingableDevices(
    subnet,
    // firstHostId: 1,
    // lastHostId: 254,
    progressCallback: (progress) {
      log.finer('Progress for host discovery : $progress');
    },
  );

  stream.listen(
    (ActiveHost host) async {
      //Same host can be emitted multiple times
      //Use Set<ActiveHost> instead of List<ActiveHost>
      log.fine('Found device: ${await host.toStringFull()}');
    },
    onDone: () {
      log.fine('Scan completed');
    },
  ); // Don't forget to cancel the stream when not in use.
}
6
likes
0
pub points
75%
popularity

Publisher

verified publisherop3nsoc13ty.blogspot.com

Extended features of network_tools package for flutter framework supporting iOS and Android

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dart_ping, dart_ping_ios, flutter, flutter_isolate, intl, logging, network_tools, universal_io

More

Packages that depend on network_tools_flutter