vpn_connection_detector 1.0.2 vpn_connection_detector: ^1.0.2 copied to clipboard
VPN connection detecting in Dart. Singleton class with state stream & connection check.
VPN Connection Detector #
The vpn_connection_detector
package provides a simple and efficient way to detect VPN connection status in a Dart/Flutter application. It includes a singleton class, VpnConnectionDetector
, that offers a stream of VPN connection states and a method to check the VPN connection status.
Features #
- Detect VPN connection status with ease.
- Detect changes in VPN connectivity and trigger events accordingly.
- Designed as a singleton for efficient resource management.
Getting Started #
Installation #
Add the vpn_connection_detector
package to your pubspec.yaml
:
dependencies:
vpn_connection_detector: ^1.0.0 # Use the latest version
Installation #
Import the package
package in your Dart/Flutter
file:
import 'package:vpn_connection_detector/vpn_connection_detector.dart';
Create a VpnConnectionDetector
Instance
final vpnDETECTOR = VpnConnectionDetector(Duration(seconds: 30));
Access the VPN Connection Stream #
VpnDetector.vpnConnectionStream.listen((state) {
if (state == VpnConnectionState.connected) {
print("VPN connected.");
// Handle VPN connected event
} else {
print("VPN disconnected.");
// Handle VPN disconnected event
}
});
Check the VPN Connection Status Manually #
bool isVpnConnected = await vpn.isVpnActive();
Dispose of the VpnConnectionDetector Instance #
VpnDetector.dispose();
Example #
For a complete example of how to use this package, please refer to the example directory.
Contributions #
Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute to the project, please feel free to create issues, submit pull requests, or reach out to us.
License #
This package is distributed under the MIT License. See LICENSE for more details.
Enjoy detecting your VPN connections with ease using the vpn_connection_detector
package!