stackonix_network_checker 1.0.3 copy "stackonix_network_checker: ^1.0.3" to clipboard
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 #

pub package likes popularity pub points License: MIT

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 #

Network Status

Offline State #

Offline State

Note: Replace placeholder images with actual screenshots of your plugin in action

�� API Reference #

Primary API #

  • NetworkChecker.isOnline() - Returns current network status as Future<bool>
  • NetworkChecker.statusStream - Stream that emits network status changes

Alternative APIs (Backward Compatibility) #

  • StackonixNetworkChecker.isOnline - Returns current network status as Future<bool>
  • StackonixNetworkChecker.onStatusChanged - Stream that emits network status changes
  • NetworkCheckerPlus.isOnline - Returns current network status as Future<bool>
  • NetworkCheckerPlus.onStatusChanged - Stream that emits network status changes

Properties #

  • bool isOnline - Current network connectivity status
  • Stream<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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License #

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author #

Stackonix - [email protected]

🙏 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!

0
likes
140
points
3
downloads

Publisher

verified publisherstackonix.com

Weekly Downloads

A Flutter plugin that provides real-time network connectivity monitoring with a simple and efficient API.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on stackonix_network_checker

Packages that implement stackonix_network_checker