NetworkInterfaceInfo class

One IPv4 interface as the OS reports it.

This exists because Dart's own NetworkInterface gives you addresses but no netmask, and without a netmask you cannot compute a broadcast address. The usual workaround — take the first three octets and append ".255" — is only correct on a /24, and silently sends UDP discovery into a black hole on the /16 and /20 networks that plenty of routers hand out.

Constructors

NetworkInterfaceInfo({required String name, required String ip, required String netmask, required String broadcast, required int prefixLength})
const
NetworkInterfaceInfo.fromMap(Map<Object?, Object?> map)
factory

Properties

broadcast → String
Directed broadcast for this interface, computed natively as (ip & netmask) | ~netmask — e.g. 10.8.15.255 for a /20, NOT 10.8.2.255.
final
hashCode → int
The hash code for this object.
no setteroverride
ip → String
IPv4 address of this interface, e.g. 10.8.2.77.
final
isCellular → bool
True for cellular data interfaces: pdp_ip* on iOS; rmnet*, ccmni*, radio* and vendor variants on Android; clat* for 464XLAT over cellular. These often carry a /32, whose computed broadcast is the interface's own address — a UDP send there goes out over mobile data and reaches nothing.
no setter
isLinkLocal → bool
True for 169.254.0.0/16 — a self-assigned address, meaning no usable network.
no setter
isLoopback → bool
True for 127.0.0.0/8.
no setter
isTunnel → bool
True for interfaces that are typically VPN tunnels rather than the LAN the user's devices are on. Broadcasting into these is what closes iOS sockets.
no setter
isUsableLan → bool
The interfaces worth broadcasting on: a real LAN, not loopback, not a self-assigned address, not a tunnel, not cellular.
no setter
name → String
Interface name as the OS reports it, e.g. en0, wlan0, utun3. Callers usually want to skip VPN tunnels (utun*, tun*, ppp*).
final
netmask → String
IPv4 netmask, e.g. 255.255.240.0.
final
prefixLength → int
Netmask as a prefix length, e.g. 20 for 255.255.240.0.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() → Map<String, dynamic>
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override