ping_discover_network 0.1.3

ping_discover_network #


Dart/Flutter library that allows to ping IP subnet and discover network devices.

Could be used to find printers (for example, on port 9100) and any other devices and services in local network.

The device should be connected to a Wi-Fi network. wifi package allows to get the local IP address / network subnet.

The library tested on both, Android and iOS platforms.

[ page] | [Documentation]

Getting Started #

Check complete examples in /example folder.

Discover available network devices in a given subnet on a given port:

import 'package:ping_discover_network/ping_discover_network.dart';

final stream ='192.168.0', 9100);

stream.listen((NetworkAddress addr) {
  if (addr.exists) {
      print('Found device: ${addr.ip}');
  }).onDone(() => print('Finish'));

Get local ip and discover network devices:

import 'package:wifi/wifi.dart';
import 'package:ping_discover_network/ping_discover_network.dart';

final String ip = await Wifi.ip;
final String subnet = ip.substring(0, ip.lastIndexOf('.'));
final int port = 80;

final stream =, port);
stream.listen((NetworkAddress addr) {
  if (addr.exists) {
    print('Found device: ${addr.ip}');

Discover available network devices in a given subnet on a given port range:

import 'package:ping_discover_network/ping_discover_network.dart';

void checkPortRange(String subnet, int fromPort, int toPort) {
  if (fromPort > toPort) {

  print('port ${fromPort}');

  final stream =, fromPort);

  stream.listen((NetworkAddress addr) {
    if (addr.exists) {
      print('Found device: ${addr.ip}:${fromPort}');
  }).onDone(() {
    checkPortRange(subnet, fromPort + 1, toPort);

checkPortRange('192.168.0', 400, 410);


  • Ping ip addresses one by one


  • Added Flutter example: get the local ip and ping the subnet

[0.1.0] - [0.1.1]

  • Ping IP subnet on a given port
  • Added example: ping ports range
  • Added documentation

[0.0.1] - [0.0.2]

  • Initial release


 * ping_discover_network
 * Created by Andrey Ushakov
 * See LICENSE for distribution and usage details.
import 'package:ping_discover_network/ping_discover_network.dart';

/// Discover available network devices in a given subnet on a given port
void main() async {
  const port = 80;
  final stream =
    timeout: Duration(milliseconds: 400),

  int found = 0;
  stream.listen((NetworkAddress addr) {
    if (addr.exists) {
      print('Found device: ${addr.ip}:$port');
  }).onDone(() => print('Finish. Found $found device(s)'));

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  ping_discover_network: ^0.1.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:ping_discover_network/ping_discover_network.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies