How to Check String is Empty or not in Dart?

We can check a string is empty or not by the String Property isEmpty. If the string is empty then it returns True if the string is not empty then it returns False.

Syntax: String.isEmpty

Return : True or False.

Example 1:
 

Dart



filter_none

edit
close

play_arrow

link
brightness_4
code

// main function start
void main() { 
    
    // initialise a string st
    String st = "";
    
    // print string is empty or not
    print(st.isEmpty); 
}

chevron_right


Output:

true

Example 2:
 

Dart

filter_none

edit
close

play_arrow

link
brightness_4
code

// main function start
void main() {
    
    // initialise a string st
    String st = "Geeksforgeeks";
    
    // print string is empty or not
    print(st.isEmpty); 
}

chevron_right


Output: 

false
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.