String trim() Method

  • Post author:
  • Post category:Dart
  • Post comments:2 Comments
String trim() Method

In this guide, we will discuss the String trim() Method in Dart Programming Language. Returns a new string by removing all leading and trailing spaces. However, this method doesn’t discard spaces between two strings.

Syntax

String.trim()

Return Type

Returns a string.

Example

void main() { 
   String str1 = "hello"; 
   String str2 = "hello world"; 
   String str3 = "hello"; 
   
   print(str1.trim()); 
   print(str2.trim()); 
   print(str3.trim()); 
} 

It will produce the following output −.

hello 
hello world 
hello

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply