阅读量:0
今天给介绍一个获取设备的网络所有相关信息插件network_info_plus
这个插件使用起来很简单,这里就不说那么多废话了直接上代码
pubspec.yaml 引入
dependencies: # 获取网络信息(IP Mac 地址等) network_info_plus: ^5.0.3
然后运行
flutter pub get
命令安装依赖。
接下来是使用
class NetWorkInfoLogic { final NetworkInfo info = NetworkInfo(); String wifiName = ""; String wifiBSSID = ""; String wifiIP = ""; String wifiIPv6 = ""; String wifiSubmask = ""; String wifiBroadcast = ""; String wifiGateway = ""; void getInfo() async { wifiName = await info.getWifiName() ?? ""; // "FooNetwork" wifiBSSID = await info.getWifiBSSID() ?? ""; // 11:22:33:44:55:66 wifiIP. = await info.getWifiIP() ?? ""; // 192.168.1.43 wifi