-
Notifications
You must be signed in to change notification settings - Fork 3
/
connectivity.dart
34 lines (30 loc) · 1.27 KB
/
connectivity.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2023, Halil Durmus. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import 'package:windows_networking/windows_networking.dart';
void printConnectionInformation(ConnectionProfile? profile) {
if (profile
case ConnectionProfile(
:final profileName,
:final isWlanConnectionProfile,
:final wlanConnectionProfileDetails
)) {
print('Profile name: $profileName');
final connectivityLevel = switch (profile.getNetworkConnectivityLevel()) {
NetworkConnectivityLevel.constrainedInternetAccess =>
'Limited Internet access.',
NetworkConnectivityLevel.internetAccess => 'Local and Internet access.',
NetworkConnectivityLevel.localAccess => 'Local network access only.',
NetworkConnectivityLevel.none => 'No connectivity.',
};
print('Connectivity level: $connectivityLevel');
if (isWlanConnectionProfile) {
final ssid = wlanConnectionProfileDetails?.getConnectedSsid();
print('Connected SSID: ${ssid ?? 'N/A'}');
}
}
}
void main() async {
final connectionProfile = NetworkInformation.getInternetConnectionProfile();
printConnectionInformation(connectionProfile);
}