urlencoding in Dart

var uri = 'http://example.org/api?foo=some message';
var encoded = Uri.encodeFull(uri);
assert(encoded == 'http://example.org/api?foo=some%20message');

var decoded = Uri.decodeFull(encoded);
assert(uri == decoded);

http://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html#ch03-uri


Update: There is now support for encode/decode URI in the Dart Uri class

Dart's URI code is placed in a separate library called dart:uri (so it can be shared between both dart:html and dart:io). It looks like it currently does not include a urlencode function so your best alternative, for now, is probably to use this Dart implementation of JavaScript's encodeUriComponent.

Tags:

Urlencode

Dart