How to encode URLs in Dart? How to encode URLs in Dart? dart dart

How to encode URLs in Dart?


You are doing too much.In this case, you only need to do: parsedData = Uri.encodeComponent(STR_DATA); to get the same result as the Python code.


Use Dart Uri Class

var uri = 'http://example.com/path/to/page?name=ferret john';var encoded = Uri.encodeFull(uri);assert(encoded == 'http://example.com/path/to/page?name=ferret%20john');var decoded = Uri.decodeFull(encoded);assert(uri == decoded);