urlencoding in Dart

后端 未结 5 2088
鱼传尺愫
鱼传尺愫 2020-12-01 13:31

Is there a function to do urlencoding in Dart? I am doing a AJAX call using XMLHttpRequest object and I need the url to be url encoded.

I did a search on dartlang.or

5条回答
  •  -上瘾入骨i
    2020-12-01 14:17

    I wrote this small function to convert a Map into a URL encoded string, which may be what you're looking for.

    String encodeMap(Map data) {
      return data.keys.map((key) => "${Uri.encodeComponent(key)}=${Uri.encodeComponent(data[key])}").join("&");
    }
    

提交回复
热议问题