-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.dart
98 lines (88 loc) · 2.09 KB
/
main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ios_network_info/ios_network_info.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _bssid = 'Unknown BSSID';
String _ssid = 'Unknown SSID';
@override
void initState() {
super.initState();
fetchAll();
}
fetchAll() {
fetchBssid();
fetchSsid();
}
fetchBssid() async {
String bssid;
try {
bssid = await IosNetworkInfo.bssid;
} on PlatformException {
bssid = 'Failed to get WiFi BSSID.';
}
setBssid(bssid);
}
setBssid(String bssid) {
if (!mounted) return;
setState(() {
_bssid = bssid;
});
}
fetchSsid() async {
String ssid;
try {
ssid = await IosNetworkInfo.ssid;
} on PlatformException {
ssid = 'Failed to get WiFi SSID.';
}
setSsid(ssid);
}
setSsid(String ssid) {
if (!mounted) return;
setState(() {
_ssid = ssid;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.black87,
title: const Text('ios_network_info'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: fetchAll,
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'SSID: $_ssid',
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 12),
Text(
'BSSID: $_bssid',
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 20),
Text('ios_network_info'),
Text('Flutter plugin example'),
],
),
),
),
);
}
}