1

I am looking for a way to get the device IP that is not based on Wifi. I am unable to find the local IP of the current device when compiling to Linux app running on an ethernet connection with no wifi card.

I tried using 'package:wifi/wifi.dart' and 'package:network_info_plus/network_info_plus.dart' to get the device's local ip and both packages gave this error: MissingPluginException (MissingPluginException(No implementation found for method ip on channel plugins.ly.com/wifi))

Is there a way to get the device local IP without a Wifi card?

UPDATE: Using https://stackoverflow.com/a/52411510/5861729 and https://stackoverflow.com/a/43803986/16477035 I was able to figure out a clean way to get my local ip.

    // Find localIp
    String localIp = '';
    final List<String> privateNetworkMasks = ['10', '172.16', '192.168'];
    for (var interface in await NetworkInterface.list()) {
      for (var addr in interface.addresses) {
        for (final possibleMask in privateNetworkMasks) {
          if (addr.address.startsWith(possibleMask)) {
            localIp = addr.address;
            break;
          }
        }
      }
    }
Samichoulo
  • 46
  • 4
  • Try to Terminate app and re run app , because most time "MissingPluginException(No implementation found)" This error come when we dont terminate app , after adding native plugin – Coder Addy Nov 11 '21 at 04:31
  • Thank for the reply, I tried refetching the packages before recompiling and got the same result. – Samichoulo Nov 11 '21 at 04:52
  • I also terminated the app before doing the refetching, with the same result – Samichoulo Nov 11 '21 at 04:54

1 Answers1

0

Run 'flutter clean' then 'flutter pub get' and re install your app

  • I had tried that too, the issue was that my PC doesn't have a wifi card so no wifi hardware was available. I found another way to find it tho I updated my question! – Samichoulo Nov 13 '21 at 06:27