String trim() Method


Advertisements

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
dart_programming_string.htm

Useful Video Courses


Video

Dart tutorial for Beginners

44 Lectures 4.5 hours

Sriyank Siddhartha

Video

Flutter Tutorial for Beginners with Dart

34 Lectures 4 hours

Sriyank Siddhartha

Video

Dart Masterclass Programming: iOS/Android Bible

69 Lectures 4 hours

Frahaan Hussain

Video

Flutter & Dart Development For Building iOS and Android Apps

117 Lectures 10 hours

Frahaan Hussain

Video

COMPLETE Google DART Programming- BOOTCAMP

22 Lectures 1.5 hours

Pranjal Srivastava

Video

AWS Mobile with Google Dart

34 Lectures 3 hours

Pranjal Srivastava

Advertisements