hardwareIp function

Future<(String, String)> hardwareIp()

Implementation

Future<(String, String)> hardwareIp() async {
  var (devid, ip) = ('', '');
  if (Platform().isWeb) {
    devid = (await PlatformDeviceId.getDeviceId)?.trim() ?? '';
  } else if (Platform().isWindows) {
    devid = await _getWinBios();
  } else {
    devid = (await PlatformDeviceId.getDeviceId)
            ?.trim()
            .replaceAll(' ', '_')
            .replaceAll('/', '-') ??
        '';
  }

  ip = await TaskEither.tryCatch(
    Ipify.ipv4,
    (final e, final _) => e,
  ).getOrElse((final _) => '0.0.0.0').run();

  return (devid, ip);
}