Encode the string component
using percent-encoding to make it
safe for literal use as a URI component.
All characters except uppercase and lowercase letters, digits and
the characters -_.!~*'()
are percent-encoded. This is the
set of characters specified in RFC 2396 and the which is
specified for the encodeUriComponent in ECMA-262 version 5.1.
When manually encoding path segments or query components remember to encode each part separately before building the path or query string.
For encoding the query part consider using encodeQueryComponent.
To avoid the need for explicitly encoding use the pathSegments and queryParameters optional named arguments when constructing a Uri.
Source
static String encodeComponent(String component) {
return _uriEncode(_unreserved2396Table, component, UTF8, false);
}