title: How to Remove New Line Only Where After The New Line There Is No Character
body: <p>As stated in the title. for example:</p>
  <blockquote>
  <p>Note: please check carefully the value of these three variables</p>
  </blockquote>
  <pre><code>String textA = 'this text contains many new line\n\n\n\nbut this ok, because there is a character after the new line';
  String textB = 'I want remove all new Line because no character after new Line\n\n\n\n';
  String textC = '\n\n\n\nAnd this still Ok, I dont want to remove all the new lines in front';
  </code></pre>
  <p>from that variable we can try print for see the result</p>
  <p>textA will be</p>
  <pre><code>this text contains many new line
  // new Line
  // new Line
  // new Line
  but this ok, because there is a character after the new line
  </code></pre>
  <p>textB will be</p>
  <pre><code>I want remove all new Line because no character after new Line
  // new Line    - I want delete this new Line
  // new Line    - I want delete this new Line
  // new Line    - I want delete this new Line
  </code></pre>
  <p>textC will be</p>
  <pre><code>// new Line
  // new Line
  // new Line
  And this still Ok, I dont want to remove all the new lines in front
  </code></pre>
  <p>you know we cant input \n (space form Enter your keyboard) to text field, when \n position in the last String, \n should be removed
  . How to solve this problem in dart or flutter?</p>