createFinalIp static method

Future<String?> createFinalIp(
  1. String? deviceIp
)

Implementation

static Future<String?> createFinalIp(String? deviceIp) async {
  if (StringUtils.isNullOrEmpty(deviceIp)) {
    NASDeviceInfo info = await NasDeviceConfig.getCurrentNasDevice();
    // 当ipAddress为空或空串时,使用NetworkConfig.baseUrl
    if (StringUtils.isNullOrEmpty(info.ipAddress)) {
      deviceIp = await NetworkConfig.baseUrl;
    } else {
      // 当port为0时,只使用ipAddress;否则使用ipAddress:port格式
      if (info.port == 0) {
        deviceIp = info.ipAddress;
      } else {
        deviceIp = "${info.ipAddress}:${info.port}";
      }
    }
  }
  return deviceIp;
}