How to Find the Length of a String in Dart?

To find a length of a string in the dart, we make use of length property of a string class in Dart. This method returns the length of string which in integer.

Syntax: string_name.length

Return Type: integer

Example: Finding the length of the string in Dart.

Dart



filter_none

edit
close

play_arrow

link
brightness_4
code

// Main function
main() {
    
  // Declaring a string variable
  String gfg = "Welcome to GeeksForGeeks";
    
  // Finding the length
  int length = gfg.length;
    
  // Printing the length of the string
  print(length);
}

chevron_right


Output:

24

Explanation: The length of the string including spaces in the above example count up to 24.

Note: The length of the empty string is equal to 0.
 

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 :

1


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