Skip to content
Related Articles

Related Articles

How to Find the Length of a String in Dart?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 15 Jul, 2020

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.


// 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



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
Recommended Articles
Page :

Start Your Coding Journey Now!