appendUrlParams method
追加url参数
params
将添加的url参数
Implementation
String appendUrlParams(Map<String, dynamic> params) {
if (params.isEmptyMap()) {
return this ?? "";
}
var index = this?.indexOf("?") ?? -1;
if (index == 0) {
return this ?? "";
}
var paramsSb = StringBuffer();
var pos = 0;
params.forEach((key, value) {
paramsSb.write("$key=$value");
if ((pos + 1) < params.length) {
paramsSb.write("&");
}
pos++;
});
if (index > 0) {
return "${this}&${paramsSb.toString()}";
} else {
return "${this}?${paramsSb.toString()}";
}
}