check_vpn_connection 0.0.2 check_vpn_connection: ^0.0.2 copied to clipboard
A simple and lightweight Flutter package that lets you define VPN connection status on your devices.
import 'package:check_vpn_connection/check_vpn_connection.dart';
import 'package:flutter/material.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: Text("Check VPN connection"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'VPN is active:',
),
FutureBuilder(
future: CheckVpnConnection.isVpnActive(),
builder: (context, AsyncSnapshot<bool> snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.toString(),
style: Theme.of(context).textTheme.headline4,
);
} else
return CircularProgressIndicator();
}),
],
),
),
);
}
}