I am currently writing an app where the user needs to know the IP address of their phone/tablet. Where would I find this information?
I only want to know what the local
This provides the IP addresses of all interfaces
import 'dart:io';
...
Future printIps() async {
for (var interface in await NetworkInterface.list()) {
print('== Interface: ${interface.name} ==');
for (var addr in interface.addresses) {
print(
'${addr.address} ${addr.host} ${addr.isLoopback} ${addr.rawAddress} ${addr.type.name}');
}
}
}
See also https://api.dartlang.org/stable/2.0.0/dart-io/NetworkInterface-class.html
Have you tried the device_info package?
There is an example on querying device information in https://pub.dartlang.org/packages/device_info#-example-tab-