title: How do I url-encode in Dart in the format that the Twitter API expects?
body: <p>I <a href="https://blog.dantup.com/2016/07/simplest-csharp-code-to-post-a-tweet-using-oauth/" rel="nofollow">wrote some code</a> to post tweets in C#. One of the things that tripped me up was the url-encoding of data since there seemed to be many options:</p>
  
  <pre><code>var input = "Hello Ladies + Gentlemen, a signed OAuth request!";
  var expected = "Hello%20Ladies%20%2B%20Gentlemen%2C%20a%20signed%20OAuth%20request%21";
  
  Console.WriteLine(WebUtility.UrlEncode(input) == expected); // False
  Console.WriteLine(Uri.EscapeUriString(input) == expected); // False
  Console.WriteLine(Uri.EscapeDataString(input) == expected); // True
  </code></pre>
  
  <p>I'm now trying to do the same thing in Dart. I've tried all the encode methods in the Uri class, but none seem to output the same.</p>
  
  <p>Code: (<a href="https://dartpad.dartlang.org/a8874dae0de40be353dace32512becfc" rel="nofollow">DartPad</a>)</p>
  
  <pre><code>print(Uri.encodeQueryComponent("Hello Ladies + Gentlemen, a signed OAuth request!"));
  print(Uri.encodeFull("Hello Ladies + Gentlemen, a signed OAuth request!"));
  print(Uri.encodeComponent("Hello Ladies + Gentlemen, a signed OAuth request!"));
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Hello+Ladies+%2B+Gentlemen%2C+a+signed+OAuth+request%21
  Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!
  Hello%20Ladies%20%2B%20Gentlemen%2C%20a%20signed%20OAuth%20request!
  </code></pre>
  
  <p>The last one (<code>encodeComponent</code>) seems the closest, just the exclamation mark is wrong.</p>
  
  <p>Is there an existing method that does this encoding as I require (the same as C#'s <code>EscapeDataString</code>)?</p>