native_ping_checker 0.0.1 copy "native_ping_checker: ^0.0.1" to clipboard
native_ping_checker: ^0.0.1 copied to clipboard

A Flutter plugin for checking internet connectivity using native ICMP ping. Supports Windows and Android with configurable settings.

Native Ping Checker #

A Flutter plugin for checking internet connectivity using native ICMP ping.

Features #

  • Native ICMP ping (no HTTP requests)
  • Windows & Android support
  • Simple Map-based configuration
  • All configuration fields are required
  • Automatic periodic checking
  • Stream-based status updates

Installation #

dependencies:
  native_ping_checker: ^0.0.1

Usage #

import 'package:native_ping_checker/native_ping_checker.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  try {
    await NativePingChecker.init(
      config: {
        'target': '8.8.8.8',
        'pingCount': 5,
        'timeoutMs': 2000,
        'minSuccessCount': 3,
        'checkIntervalSeconds': 30,
      },
      autoStartPeriodicCheck: true,
      onStatusChange: (isConnected) {
        print('Connection: ${isConnected ? "Online" : "Offline"}');
      },
    );

    runApp(MyApp());
  } on PingConfigException catch (e) {
    print(e.message);
  }
}

Configuration #

All fields are required:

Field Type Description
target String IP address or domain to ping
pingCount int Number of ping attempts
timeoutMs int Timeout per ping (ms)
minSuccessCount int Minimum successful pings
checkIntervalSeconds int Interval between checks (seconds)

API #

Initialize #

await NativePingChecker.init(
  config: {...},
  autoStartPeriodicCheck: true,  // default: true
  onStatusChange: (isConnected) {},
);

Check Once #

bool isOnline = await NativePingChecker.checkConnection();

Stream #

NativePingChecker.connectionStream.listen((isConnected) {
  print('Status: $isConnected');
});

Control #

NativePingChecker.startPeriodicCheck();
NativePingChecker.stopPeriodicCheck();
NativePingChecker.dispose();

Properties #

bool lastStatus = NativePingChecker.lastStatus;
bool isRunning = NativePingChecker.isPeriodicCheckRunning;
bool isInit = NativePingChecker.isInitialized;
PingConfig config = NativePingChecker.config;

Platform Support #

Platform Status
Windows Supported
Android Supported
iOS Planned
macOS Planned

License #

MIT License

0
likes
160
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for checking internet connectivity using native ICMP ping. Supports Windows and Android with configurable settings.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on native_ping_checker

Packages that implement native_ping_checker