fetchNetworkInterfaces method

  1. @override
Future<List<NetworkInterfaceInfo>> fetchNetworkInterfaces()
override

Every IPv4 interface with its netmask and directed broadcast address.

Needs no permission: this reads the local interface table (getifaddrs on iOS, java.net.NetworkInterface on Android), not the WiFi identity that resolveSSID needs Location for.

Implementation

@override
Future<List<NetworkInterfaceInfo>> fetchNetworkInterfaces() async {
  // Same "empty list, never throw" contract as SSIDResolver: callers use
  // this to decide where to send discovery traffic, and the two entry points
  // must not differ in error behaviour.
  try {
    final result = await methodChannel.invokeMethod<List<Object?>>('fetchNetworkInterfaces');
    if (result == null) return const <NetworkInterfaceInfo>[];
    return result
        .whereType<Map<Object?, Object?>>()
        .map(NetworkInterfaceInfo.fromMap)
        .toList(growable: false);
  } on PlatformException {
    return const <NetworkInterfaceInfo>[];
  } on MissingPluginException {
    return const <NetworkInterfaceInfo>[];
  }
}