1

I want to build a android app using flutter to change dns of the wifi that the device connected to so does flutter have any library to do that or do you guys have any suggestion for me. I really appreciated and thank you for your time.

I have tried some library like wifi_info_plus or android_intent but still not work. Like wifi_info only get wifi address or dns but it doesn't have any funtion to change dns

  • It's a quit challengig task . Create your own plugin to edit the dns . https://stackoverflow.com/questions/4106502/set-android-ip-dns-gateway-setting-programmatically – Rahul Kushwaha Jun 14 '23 at 06:02
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 15 '23 at 05:35

1 Answers1

0

There is no Android API to change the DNS server, at least on an unrooted phone; this must be done by each user through their phone's wifi settings. This is actually a good thing - if an app could easily hijack DNS servers that could be catastrophic for internet security.

However, there may be a potential alternative. There are apps that provide DNS settings, but by masquerading as a VPN. 1.1.1.1 from cloudflare is probably the most prominent example of this. However, what it does it probably not very easy to do from Flutter, as it involves a great deal of native android code and likely some server backend (not sure about that but it seems likely). I doubt very much that there is a flutter package providing this functionality.

Your best bet would be to figure out how this is done in native android code, and then expose it through a platform channel to dart.

rmtmckenzie
  • 37,718
  • 9
  • 112
  • 99