@@ -12,8 +12,6 @@ import 'package:flutter/foundation.dart';
12
12
import 'package:flutter/material.dart' ;
13
13
import 'package:flutter/services.dart' ;
14
14
15
- // ignore_for_file: deprecated_member_use
16
-
17
15
// Sets a platform override for desktop to avoid exceptions. See
18
16
// https://flutter.dev/desktop#target-platform-override for more info.
19
17
void _enablePlatformOverrideForDesktop () {
@@ -100,73 +98,6 @@ class _MyHomePageState extends State<MyHomePage> {
100
98
}
101
99
102
100
Future <void > _updateConnectionStatus (ConnectivityResult result) async {
103
- switch (result) {
104
- case ConnectivityResult .wifi:
105
- String wifiName, wifiBSSID, wifiIP;
106
-
107
- try {
108
- if (! kIsWeb && Platform .isIOS) {
109
- var status = await _connectivity.getLocationServiceAuthorization ();
110
- if (status == LocationAuthorizationStatus .notDetermined) {
111
- status =
112
- await _connectivity.requestLocationServiceAuthorization ();
113
- }
114
- if (status == LocationAuthorizationStatus .authorizedAlways ||
115
- status == LocationAuthorizationStatus .authorizedWhenInUse) {
116
- wifiName = await _connectivity.getWifiName ();
117
- } else {
118
- wifiName = await _connectivity.getWifiName ();
119
- }
120
- } else {
121
- wifiName = await _connectivity.getWifiName ();
122
- }
123
- } on PlatformException catch (e) {
124
- print (e.toString ());
125
- wifiName = 'Failed to get Wifi Name' ;
126
- }
127
-
128
- try {
129
- if (! kIsWeb && Platform .isIOS) {
130
- var status = await _connectivity.getLocationServiceAuthorization ();
131
- if (status == LocationAuthorizationStatus .notDetermined) {
132
- status =
133
- await _connectivity.requestLocationServiceAuthorization ();
134
- }
135
- if (status == LocationAuthorizationStatus .authorizedAlways ||
136
- status == LocationAuthorizationStatus .authorizedWhenInUse) {
137
- wifiBSSID = await _connectivity.getWifiBSSID ();
138
- } else {
139
- wifiBSSID = await _connectivity.getWifiBSSID ();
140
- }
141
- } else {
142
- wifiBSSID = await _connectivity.getWifiBSSID ();
143
- }
144
- } on PlatformException catch (e) {
145
- print (e.toString ());
146
- wifiBSSID = 'Failed to get Wifi BSSID' ;
147
- }
148
-
149
- try {
150
- wifiIP = await _connectivity.getWifiIP ();
151
- } on PlatformException catch (e) {
152
- print (e.toString ());
153
- wifiIP = 'Failed to get Wifi IP' ;
154
- }
155
-
156
- setState (() {
157
- _connectionStatus = '$result \n '
158
- 'Wifi Name: $wifiName \n '
159
- 'Wifi BSSID: $wifiBSSID \n '
160
- 'Wifi IP: $wifiIP \n ' ;
161
- });
162
- break ;
163
- case ConnectivityResult .mobile:
164
- case ConnectivityResult .none:
165
- setState (() => _connectionStatus = result.toString ());
166
- break ;
167
- default :
168
- setState (() => _connectionStatus = 'Failed to get connectivity.' );
169
- break ;
170
- }
101
+ setState (() => _connectionStatus = result.toString ());
171
102
}
172
103
}
0 commit comments