rebuildUrl method

Future<String> rebuildUrl(
  1. String? deviceIp,
  2. String apiPath,
  3. Map<String, dynamic>? pathParams
)

Implementation

Future<String> rebuildUrl(
  String? deviceIp,
  String apiPath,
  Map<String, dynamic>? pathParams,
) async {
  String baseUrl;
  if (deviceIp != null) {
    // 检查deviceIp是否已经以http://或https://开头
    if (deviceIp.startsWith('http://') || deviceIp.startsWith('https://')) {
      baseUrl = deviceIp;
    } else {
      baseUrl = 'http://$deviceIp';
    }
  } else {
    baseUrl = await getDefaultPath();
  }
  String fullPath = '$baseUrl$apiPath';
  fullPath = appendQueryParameters(fullPath, pathParams);
  return fullPath;
}