4

I am working on a Flutter app that needs to scan for WIFI networks and be able to connect and disconnect to/from these.

I have tried to use wifi_configuration which works with Android 9(API level 28) but not above this.

I also tried using the following libraries, wifi_iot, wifi, which does not seem to support Android 10 and 11.

Do you know if there exist any library that support these actions in Android 9, 10 and 11?

I have also tried to find a Java or Kotlin library that supports these features for the different Android version. I can create a method-channel to communicate to these from my Flutter app, but I have not be able to find any libraries that have support for these different Android version. Are there any libraries/packages in Java/Kotlin that can accomplish this?

Daniel
  • 546
  • 6
  • 17
  • Have you tried [Connectivity](https://pub.dev/packages/connectivity) package? – Andrey Gritsay Jan 12 '21 at 10:07
  • 1
    [flutter_wifi_connect 0.0.7 ](https://pub.dev/packages/flutter_wifi_connect) – Usama Altaf Jan 12 '21 at 10:38
  • @AndreyGritsay From my understanding https://pub.dev/packages/connectivity is only able to provide information about whether the device is on mobile or WIFI network. Connecting/disconnecting and scanning for WIFI networks is not supported – Daniel Jan 12 '21 at 12:21
  • @Daniel Did you find any solution to this issue? I'm using wifi_iot package but it is working only in Android 10 for my case. I need solution for the other versions. – Oğuzhan Koşar Mar 30 '21 at 11:51

1 Answers1

2

I'm using wifi_iot. scan, connect & disconnects is working on android 11.

use WiFiForIoTPlugin.loadWifiList() for scanning available networks

// scanning
final wifis = await WiFiForIoTPlugin.loadWifiList();
log("${wifis.map((e) => e.ssid).toList()}");

// connecting
final ssid = "test network";
final res = await WiFiForIoTPlugin.connect(
        ssid,
        password: "12345678",
        security: NetworkSecurity.WPA,
        withInternet: false,
      );
if (res)
  print("connected")


Ali80
  • 6,333
  • 2
  • 43
  • 33
  • Can you add your code where connect and disconnect to a network found via WiFiForIoTPlugin.loadWifiList()? – Daniel Dec 03 '21 at 09:26
  • For their class WiFIForIoTPlugin which has the connect() method they have the following deprecated tag: "This is will only work with < Android SDK 26. It could be made to work for >= Android SDK 29, request at https://github.com/alternadom/WiFiFlutter/issues/134." – Daniel Dec 03 '21 at 09:32
  • @Daniel I used sdk 31 and android 11, both `loadWifiList()` and `connect()` worked as expected – Ali80 Dec 04 '21 at 12:19