Last active
February 29, 2020 11:13
-
-
Save luizmarcus/bc911e91b615e22bea5ff60255bde8c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:connectivity/connectivity.dart'; | |
String _connection = ""; | |
final Connectivity _connectivity = Connectivity(); | |
@override | |
void initState() { | |
super.initState(); | |
_connectivity.checkConnectivity().then((connectivityResult){_updateStatus(connectivityResult);}); | |
} | |
void _updateStatus(ConnectivityResult connectivityResult) async{ | |
if (connectivityResult == ConnectivityResult.mobile) { | |
updateText("3G/4G"); | |
} else if (connectivityResult == ConnectivityResult.wifi) { | |
String wifiName = await _connectivity.getWifiName(); | |
String wifiSsid = await _connectivity.getWifiBSSID(); | |
String wifiIp = await _connectivity.getWifiIP(); | |
updateText("Wi-Fi\n$wifiName\n$wifiSsid\n$wifiIp"); | |
}else{ | |
updateText("Não Conectado!"); | |
} | |
} | |
void updateText(String texto){ | |
setState(() { | |
_connection = texto; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment