vpn_connection_monitor 1.0.2 copy "vpn_connection_monitor: ^1.0.2" to clipboard
vpn_connection_monitor: ^1.0.2 copied to clipboard

discontinuedreplaced by: vpn_connection_detector
outdated

VpnConnectionMonitor is a Dart package that monitors the connection status of a VPN. It provides a singleton class with a stream of VpnConnectionState events and a method to check if the VPN is connected.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:vpn_connection_monitor/vpn_connection_monitor.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final stream = VpnConnectionMonitor();

  @override
  void dispose() {
    stream.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Vpn Connection Monitor"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'VPN is active:',
            ),
            StreamBuilder<VpnConnectionState>(
                stream: stream.vpnConnectionStream,
                builder: (context, AsyncSnapshot<VpnConnectionState> snapshot) {
                  if (snapshot.hasData) {
                    return Text(
                      snapshot.data.toString(),
                      style: Theme.of(context).textTheme.headlineMedium,
                    );
                  } else {
                    return const CircularProgressIndicator();
                  }
                }),
          ],
        ),
      ),
    );
  }
}
0
likes
0
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

VpnConnectionMonitor is a Dart package that monitors the connection status of a VPN. It provides a singleton class with a stream of VpnConnectionState events and a method to check if the VPN is connected.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

connectivity_plus, flutter

More

Packages that depend on vpn_connection_monitor