LanUtils class
局域网 IPv4 获取工具
返回当前设备的首选局域网 IPv4:优先常见私网段 (192.168.x > 10.x > 172.16-31.x > 其它公网地址),排除环回与 APIPA(169.254.x.x),虚拟网卡(Docker / VPN / 虚拟化平台等)仅降权 垫底、不排除。能力吸收自 saas_pos 收银端同名实现并按本库基线重写。
纯 dart:io 实现,无第三方依赖,可用于 Android / iOS / macOS /
Windows / Linux(web 不可用,dart:io 限制)。
best-effort 说明:虚拟网卡识别是接口名子串启发式
(_virtualNameMarkers),无法覆盖所有形态;多网卡设备上启发式结果
未必符合预期,调用方不应将其用于安全决策。
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getPreferredLanIpv4(
) → Future< String?> - 获取当前设备首选局域网 IPv4(完整点分四段地址)。
-
pickBestLanIpv4(
List< ({List< interfaces) → String?String> ipv4, String name})> - 从接口快照中选出首选 IPv4 地址(纯函数,供 getPreferredLanIpv4 与测试共用)。