0 purchases
vpn connection detector
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.6 # Use the latest version
copied to clipboard
Usage #
Import the package package in your Dart/Flutter file:
import 'package:vpn_connection_detector/vpn_connection_detector.dart';
copied to clipboard
Create a VpnConnectionDetector Instance
final vpnDetector = VpnConnectionDetector();
copied to clipboard
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
}
});
copied to clipboard
Check the VPN Connection Status Manually #
bool isVpnConnected = await VpnConnectionDetector.isVpnActive();
copied to clipboard
Dispose of the VpnConnectionDetector Instance #
If using vpnConnectionStream, remember to dispose. Otherwise, use VpnConnectionDetector.isVpnActive() function without concerns.
vpnDetector.dispose();
copied to clipboard
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!
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.