stackonix_network_checker 1.0.3
stackonix_network_checker: ^1.0.3 copied to clipboard
A Flutter plugin that provides real-time network connectivity monitoring with a simple and efficient API.
Stackonix Network Checker #
A Flutter plugin that provides real-time network connectivity monitoring with a simple and efficient API. Monitor network status changes, check current connectivity, and receive real-time updates across your Flutter application.
✨ Features #
- 🔌 Real-time monitoring - Get instant notifications when network status changes
- 📱 Cross-platform - Works seamlessly on Android and iOS
- ⚡ Lightweight - Minimal overhead with efficient implementation
- 🔄 Stream-based - Continuous network status updates via streams
- 📊 Status checking - Check current network connectivity status
- 🎯 Simple API - Easy to integrate with minimal code
- 🚀 Performance optimized - Built for high-performance applications
- 🔒 Verified Publisher - Published by verified Stackonix team
📦 Installation #
Add this to your package's pubspec.yaml file:
dependencies:
stackonix_network_checker: ^1.0.3
Or install it from the command line:
flutter pub add stackonix_network_checker
🚀 Usage #
Basic Network Status Check #
import 'package:stackonix_network_checker/stackonix_network_checker.dart';
// Check if device is currently online
bool isOnline = await NetworkChecker.isOnline();
print('Is online: $isOnline');
// Alternative API (backward compatibility)
bool isOnline = await StackonixNetworkChecker.isOnline;
print('Is online: $isOnline');
Real-time Network Monitoring #
import 'package:stackonix_network_checker/stackonix_network_checker.dart';
class NetworkStatusWidget extends StatefulWidget {
@override
_NetworkStatusWidgetState createState() => _NetworkStatusWidgetState();
}
class _NetworkStatusWidgetState extends State<NetworkStatusWidget> {
bool _isOnline = true;
@override
void initState() {
super.initState();
_listenToNetworkChanges();
}
void _listenToNetworkChanges() {
NetworkChecker.statusStream.listen((bool isOnline) {
setState(() {
_isOnline = isOnline;
});
// Show user feedback
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(isOnline ? 'Connected to network' : 'No network connection'),
backgroundColor: isOnline ? Colors.green : Colors.red,
),
);
});
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: _isOnline ? Colors.green.shade100 : Colors.red.shade100,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Icon(
_isOnline ? Icons.wifi : Icons.wifi_off,
color: _isOnline ? Colors.green : Colors.red,
),
SizedBox(width: 8),
Text(
_isOnline ? 'Online' : 'Offline',
style: TextStyle(
fontWeight: FontWeight.bold,
color: _isOnline ? Colors.green.shade800 : Colors.red.shade800,
),
),
],
),
);
}
}
Advanced Usage with Stream Controller #
import 'package:stackonix_network_checker/stackonix_network_checker.dart';
class NetworkService {
static final NetworkService _instance = NetworkService._internal();
factory NetworkService() => _instance;
NetworkService._internal();
Stream<bool> get networkStatusStream => NetworkChecker.statusStream;
Future<bool> get currentStatus async => await NetworkChecker.isOnline();
void dispose() {
// Clean up resources if needed
}
}
// Usage in your app
final networkService = NetworkService();
// Listen to network changes
networkService.networkStatusStream.listen((isOnline) {
if (isOnline) {
// Resume network operations
_resumeNetworkOperations();
} else {
// Pause network operations
_pauseNetworkOperations();
}
});
📱 Screenshots #
Network Status Indicator #
Offline State #
Note: Replace placeholder images with actual screenshots of your plugin in action
�� API Reference #
Primary API #
NetworkChecker.isOnline()- Returns current network status asFuture<bool>NetworkChecker.statusStream- Stream that emits network status changes
Alternative APIs (Backward Compatibility) #
StackonixNetworkChecker.isOnline- Returns current network status asFuture<bool>StackonixNetworkChecker.onStatusChanged- Stream that emits network status changesNetworkCheckerPlus.isOnline- Returns current network status asFuture<bool>NetworkCheckerPlus.onStatusChanged- Stream that emits network status changes
Properties #
bool isOnline- Current network connectivity statusStream<bool> statusStream- Stream of network status updates
🛠️ Platform Support #
| Platform | Support |
|---|---|
| Android | ✅ Full support |
| iOS | ✅ Full support |
| Web | ❌ Not supported |
| Windows | ❌ Not supported |
| macOS | ❌ Not supported |
| Linux | ❌ Not supported |
📋 Requirements #
- Flutter: >=3.10.0
- Dart: >=3.0.0
- Android: API level 21+
- iOS: 12.0+
🤝 Contributing #
We welcome contributions! Please feel free to submit issues and pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.
👨💻 Author #
Stackonix - [email protected]
- Website: https://stackonix.com
- GitHub: https://github.com/stackonix
🙏 Acknowledgments #
- Flutter team for the amazing framework
- All contributors and users of this plugin
- The open-source community for inspiration and support
⭐ Star this repository if you find it helpful!