Dart String Manipulations: Trimming & Padding
Jeet Bhalu
1 min read
Trimming:
- You can remove in String Whitespace in to use function trim() ,
Right side to remove String Whitespace in to use function trimRight() ,
Left Side to remove String white space in to use function trimLeft() .
void main(){
String str = " Hello Jeet How are You! ";
print(str.trim());
print(str.trimLeft());
print(str.trimRight());
}
Output:
Hello Jeet How are You!
Hello Jeet How are You!
Hello Jeet How are You!
Padding:
- You can add Padding space in Your String sentence in padding add using padLeft() and padRight() function to use padding set in Your string sentence
void main()
{
String str1 = "Jeet";
print(str1.padLeft(10,'--'));
print(str1.padRight(3));
}
Output:
----------Jeet
Jeet
0
Subscribe to my newsletter
Read articles from Jeet Bhalu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Dart String Manipulations: Trimming & PaddingTrimming & PaddingTrimming vs PaddingJeet Bhalu#Jeetbhalubhalutrimming and paddingpaddingDart#dart language#dart-for-beginnersdart programming tutorial#dart-keywordsstring manipulation
Written by
Jeet Bhalu
Jeet Bhalu
i am Jeet Bhalu i am flutter App developer