The Dart String Trim method

Aug 22, 2021 . 0 min Muhammed Mukhthar CM
Cover Image

The Dart trim() method returns the given String after removing whitespaces at the beginning and end of the String.


" SampleText".trim() // "SampleText"
"SampleText ".trim() // "SampleText"
" SampleText ".trim() // "SampleText"
"SampleText".trim() // "SampleText"

Note that, this will not remove whitespace in the middle of a sentence.