mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 18:04:18 +01:00
20 lines
541 B
Dart
20 lines
541 B
Dart
import 'dart:io';
|
|
|
|
class IpUtil {
|
|
static Future<String?> getIp() async {
|
|
var ips = await NetworkInterface.list();
|
|
for (var interface in ips) {
|
|
print('== Interface: ${interface.name} ==');
|
|
if ((interface.name.toLowerCase()).contains("wlan")) {
|
|
for (var addr in interface.addresses) {
|
|
print(
|
|
'${addr.address} ${addr.host} ${addr.isLoopback} ${addr.rawAddress} ${addr.type.name}');
|
|
return addr.address;
|
|
}
|
|
}
|
|
}
|
|
|
|
return ips.first.addresses.first.address;
|
|
}
|
|
}
|