vpn_info

Creator: coderz1093

Last updated:

0 purchases

vpn_info Image
vpn_info Images

Languages

Categories

Add to Cart

Description:

vpn info

vpn_info #


A Flutter package that provides utilities for checking VPN connection status and obtaining details about the connected VPN.

Note: This package is in active development. Feel free to use it, and contributions are welcome.

Table of Contents #

Installation
Usage
Methods
Example
Issues
Contributing

Installation #
Add vpn_info to your pubspec.yaml file:

dependencies:
vpn_info: ^1.0.0

copied to clipboard
Run the following command to install the package:
$ flutter pub get
copied to clipboard
Usage #
Import the package:

import 'package:vpn_info/vpn_info.dart';

copied to clipboard
Methods #
Future<bool> isVpnConnected() #
Check if the device has an active VPN connection.

bool vpnConnected = await VpnInfo.isVpnConnected();

copied to clipboard
Future<String?> getConnectedVpnProtocolName() #
Get the name of the connected VPN interface.

String? vpnInterfaceName = await VpnInfo.getConnectedVpnProtocolName();

// Perform a null check later in code

copied to clipboard
Future<List<InternetAddress>?> getConnectedVpnAddresses() #
Get the IP Address and version of the connected VPN interface as a list of InternetAddress objects.

List<InternetAddress>? vpnInterfaceName = await VpnInfo.getConnectedVpnAddresses();

// Perform a null check later in code

copied to clipboard
Example #

import 'dart:io';

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

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("VPN Info"),
),
body: Center(
child: Column(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text('VPN connected:'),
const SizedBox(width: 10.0),
FutureBuilder(
future: VpnInfo.isVpnConnected(),
builder: (context, AsyncSnapshot<bool> snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.toString(),
style: Theme.of(context).textTheme.headlineMedium,
);
} else {
return const CircularProgressIndicator();
}
},
),
],
),
const SizedBox(height: 20.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text('VPN name:'),
const SizedBox(width: 10.0),
FutureBuilder(
future: VpnInfo.getConnectedVpnProtocolName(),
builder: (context, AsyncSnapshot<String?> snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.toString(),
style: Theme.of(context).textTheme.headlineMedium,
);
} else {
return Text(
'No VPN',
style: Theme.of(context).textTheme.headlineMedium,
);
}
},
),
],
),
const SizedBox(height: 20.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text('VPN addresses:'),
const SizedBox(width: 10.0),
FutureBuilder(
future: VpnInfo.getConnectedVpnAddresses(),
builder: (context,
AsyncSnapshot<List<InternetAddress>?> snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.toString(),
style: Theme.of(context).textTheme.headlineMedium,
);
} else {
return Text(
'No VPN',
style: Theme.of(context).textTheme.headlineMedium,
);
}
},
),
],
),
],
),
),
);
}
}


copied to clipboard
Issues #
Found a bug or have a feature request? Create an issue on the GitHub Issues page.
Contributing #
Contributions are welcome! Fork the repo, make your changes, and submit a pull request.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.