rebuildUrl method
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;
}