Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: network_info_plus can not get the WifiGatewayIP. #3265

Open
8 tasks done
ykwang opened this issue Sep 24, 2024 · 2 comments
Open
8 tasks done

[Question]: network_info_plus can not get the WifiGatewayIP. #3265

ykwang opened this issue Sep 24, 2024 · 2 comments
Labels
invalid Bad description, irrelevant information, not related to the plugin, etc. question Further information is requested

Comments

@ykwang
Copy link

ykwang commented Sep 24, 2024

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
@ykwang ykwang added the question Further information is requested label Sep 24, 2024
@miquelbeltran
Copy link
Member

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.

@miquelbeltran miquelbeltran added the invalid Bad description, irrelevant information, not related to the plugin, etc. label Sep 24, 2024
@zhangyibo007
Copy link

插件 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网站上使用,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Bad description, irrelevant information, not related to the plugin, etc. question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants