Skip to main content

net_checker 0.0.7 copy "net_checker: ^0.0.7" to clipboard
net_checker: ^0.0.7 copied to clipboard

A lightweight Flutter package to check internet connectivity, monitor connection changes, measure latency, and detect network quality.

net_checker #

pub version likes license

A lightweight and cross-platform Flutter package to check internet connectivity, monitor connection changes, measure latency, detect network quality, and identify working hosts.


Quick Example #

final connected = await InternetChecker.hasConnection();

if (connected) {
  print("Connected");
} else {
  print("No Internet");
}

Features #

Feature Supported
Internet connectivity check ✓
Real-time connection monitoring ✓
Network latency measurement ✓
Network quality detection ✓
Working host detection ✓
Custom host configuration ✓
UI widgets for connectivity status ✓
Cross-platform support ✓

Platform Support #

Platform Supported Notes
Android ✓ Requires INTERNET permission
iOS ✓ No extra permission required
Web ✓ Wasm & JS compatible (dart.library.js_interop)
Windows ✓ No extra setup
macOS ✓ No extra setup
Linux ✓ No extra setup

Why net_checker? #

Unlike basic connectivity packages, net_checker provides:

  • Real internet access check (not just network type)
  • Built-in latency measurement
  • Network quality detection (Good / Poor / etc.)
  • Working host detection
  • Ready-to-use UI widgets

All in one lightweight package.


Installation #

dependencies:
  net_checker: ^0.0.7
flutter pub get

Import #

import 'package:net_checker/net_checker.dart';

Check Internet Connection #

bool connected = await InternetChecker.hasConnection();

Get Working Host #

String? host = await InternetChecker.getWorkingHost();

Network Latency #

int? latency = await LatencyChecker.getLatency();

Network Quality #

// As a strongly-typed enum
NetworkQualityLevel level = await NetworkQuality.getQualityLevel();
print(level.label); // "Excellent", "Good", "Slow", "Very Slow", "Disconnected"
print(level.color); // Colors.green, Colors.orange, etc.

// Or as a string (backward compatible)
String quality = await NetworkQuality.getQuality();

Listen to Connection Changes #

InternetConnectionStream.start().listen((status) {
  if (status.isConnected) {
    print("Online: ${status.label}");
  } else {
    print("Offline");
  }
});

Custom Configuration #

final config = InternetConfig(
  hosts: ["google.com", "cloudflare.com", "1.1.1.1"],
  timeout: Duration(seconds: 3),
  checkInterval: Duration(seconds: 5),
);

Usage with config #

await InternetChecker.hasConnection(config: config);
await LatencyChecker.getLatency(config: config);
await NetworkQuality.getQuality(config: config);
await InternetChecker.getWorkingHost(config: config);

Widgets #

Internet Status Indicator #

InternetStatusIndicator(
  size: 28,
  connectedColor: Colors.green,
  disconnectedColor: Colors.red,
)

Internet Status Builder #

InternetStatusBuilder(
  builder: (context, status) {
    if (status.isConnected) {
      return Text("Online: ${status.label}");
    }
    return const Text("Offline");
  },
)

No Internet Banner #

NoInternetBanner(
  visible: !isConnected,
  message: "No Internet Connection",
  animated: true,
)

Use Cases #

  • Show offline banner in apps
  • Retry API calls automatically
  • Monitor connection quality
  • Detect slow networks

Platform Configuration #

Android #

Add permission in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

iOS #

No additional permission required.

If using network calls extensively, ensure App Transport Security allows your endpoints if needed:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

Web #

  • Uses browser-based network detection
  • Subject to CORS and browser security restrictions
  • Connectivity checks may not fully match mobile/desktop behavior
  • Host verification and latency may be limited

Desktop (Windows / macOS / Linux) #

No additional configuration required.


Best Practices #

  • Use default configuration unless needed
  • Avoid very low checkInterval (e.g. < 2 seconds) as it may increase network usage
  • Use multiple hosts for reliability

Author #

Developed and maintained by Lionheartapps
https://www.lionheartapps.com


Support the Project #

If you find net_checker useful, you can support its development.

Buy Me A Coffee

License #

MIT License

Screenshots #

Connected Disconnected

1
likes
150
points
404
downloads

Documentation

API reference

Publisher

verified publisherlionheartapps.com

Weekly Downloads

A lightweight Flutter package to check internet connectivity, monitor connection changes, measure latency, and detect network quality.

Homepage
Repository (GitHub)
View/report issues

Topics

#connectivity #internet #network #flutter

License

MIT (license)

Dependencies

flutter, web

More

Packages that depend on net_checker