How to Find the Length of a String in Dart?
Last Updated :
15 Jul, 2020
Improve
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
// 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); } |
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.