net_checker 0.0.4
net_checker: ^0.0.4 copied to clipboard
A lightweight Flutter package to check internet connectivity, monitor connection changes, measure latency, and detect network quality.
net_checker #
A lightweight Flutter package to check internet connectivity, monitor connection changes, measure latency, and detect network quality.
Features #
| Feature | Supported |
|---|---|
| Internet connectivity check | ✓ |
| Real-time connection monitoring | ✓ |
| Network latency measurement | ✓ |
| Network quality detection | ✓ |
| Custom host configuration | ✓ |
| UI widgets for connectivity status | ✓ |
| Cross platform support | ✓ |
Platform Support #
| Platform | Supported |
|---|---|
| Android | ✓ |
| iOS | ✓ |
| Web | ✓ |
| Windows | ✓ |
| macOS | ✓ |
| Linux | ✓ |
Installation #
Add this to your pubspec.yaml
dependencies:
net_checker: ^latest
Then run
flutter pub get
Import #
import 'package:net_checker/net_checker.dart';
Check Internet Connection #
bool connected = await InternetChecker.hasConnection();
print("Connected: $connected");
Custom Configuration #
final config = InternetConfig(
hosts: ["example.com", "cloudflare.com", "8.8.8.8"],
timeout: Duration(seconds: 3),
checkInterval: Duration(seconds: 5),
);
Use it like this
bool connected = await InternetChecker.hasConnection(config: config);
Listen to Internet Changes #
InternetConnectionStream.start().listen((status) {
print(status);
});
Network Latency #
int? latency = await LatencyChecker.getLatency();
print("Latency: $latency ms");
Network Quality #
String quality = await NetworkQuality.getQuality();
print("Connection quality: $quality");
Widgets #
Internet Status Indicator #
InternetStatusIndicator()
Internet Status Builder #
InternetStatusBuilder(
builder: (context, status) {
return Text(status.toString());
},
)
No Internet Banner #
NoInternetBanner(
visible: true,
)