[Question]: network_info_plus can not get the WifiGatewayIP.
Opened this issue · 2 comments
What is your question?
I can get getWifiName by network_info_plus .
But Can not get the GatewayIP.
Checklist before submitting a question
- I searched issues in this repository and couldn't find such bug/problem
- I Google'd a solution and I couldn't find it
- I searched on StackOverflow for a solution and I couldn't find it
- I read the README.md file of the plugin
- I am using the latest version of the plugin
- All dependencies are up to date with
flutter pub upgrade
- I did a
flutter clean
- I tried running the example project
You need to provide more details in your question, like which platform are you using, which plugin version, if you ran the example project, etc.
插件 getGatewayIPAddress 方法
val linkAddresses =
connectivityManager?.getLinkProperties(connectivityManager.activeNetwork) 获取的是可用的网络,并不是连接的wifi网络,比如说你同时连接wifi网络,和5G网络,并且正巧你的wifi网络不可用获取的就是5G网络的网关地址,所有需要修改插件源码:
val networks = connectivityManager.allNetworks
for (network in networks) {
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
if (networkCapabilities != null && networkCapabilities.hasTransport(
NetworkCapabilities.TRANSPORT_WIFI)) {
// 获取 Wi-Fi 的 LinkProperties
val linkProperties = connectivityManager.getLinkProperties(network)
Log.d("TAG", "Wi-Fi LinkProperties: $linkProperties")
Log.d("TAG", "Wi-Fi LinkProperties dhcpServerAddress : ${linkProperties!!.dhcpServerAddress!!.hostAddress}")
}
},希望作者能重新加一个新的方法,获取修改下方法,再次上传到pub网站上使用,谢谢