network_watcher 0.0.1
network_watcher: ^0.0.1 copied to clipboard
A robust Flutter plugin for monitoring network connectivity changes with support for WiFi, Mobile, Ethernet, VPN, and Bluetooth connections on Android and iOS.
0.0.1 #
Initial Release #
Features
- ✅ Real-time network connectivity monitoring via streams
- ✅ One-time connectivity checks
- ✅ Support for multiple connection types:
- WiFi
- Mobile/Cellular
- Ethernet
- VPN
- Bluetooth
- Other/Unknown
- ✅ Cross-platform support (Android & iOS)
- ✅ Null-safe API with strong typing
- ✅ Comprehensive error handling
Android Implementation
- ✅ Uses
ConnectivityManagerandNetworkCallbackfor modern Android (API 24+) - ✅ Fallback to
BroadcastReceiverfor older Android versions - ✅ Proper lifecycle management to prevent memory leaks
- ✅ Thread-safe implementation with Handler for UI updates
- ✅ Handles edge cases (airplane mode, network switching, etc.)
iOS Implementation
- ✅ Uses
NWPathMonitorfrom Network framework (iOS 12+) - ✅ Fallback to
SCNetworkReachabilityfor iOS < 12 - ✅ Proper cleanup to prevent memory leaks
- ✅ Main thread dispatch for stream events
API
- ✅
NetworkWatcher.instance.checkConnectivity()- Check current connectivity - ✅
NetworkWatcher.instance.onConnectivityChanged- Stream of connectivity changes - ✅
ConnectivityResultclass with convenience getters:isConnected- Whether any connection existsisWifi- Connected to WiFiisMobile- Connected to mobile dataisEthernet- Connected to ethernetisVpn- Connected via VPNisBluetooth- Connected via bluetooth
- ✅
ConnectivityTypeenum for type-safe connection types
Testing
- ✅ Comprehensive unit tests
- ✅ Platform channel mock testing
- ✅ Stream functionality tests
- ✅ Edge case and error handling tests
Documentation
- ✅ Comprehensive README with examples
- ✅ API documentation
- ✅ Example app demonstrating all features
- ✅ Platform-specific setup instructions
- ✅ Troubleshooting guide
Example App
- ✅ Real-time connectivity monitoring
- ✅ Connection history tracking
- ✅ Visual status indicators
- ✅ Start/stop monitoring controls
- ✅ Material Design 3 UI