How to Find the Length of a String in Dart? (original) (raw)
Last Updated : 07 Apr, 2025
To find the length of a string in the dart, we make use of the length property of a string class in Dart. This method returns the length of the string, which is an integer.
**Syntax: string_name.length
**Return Type: Integer
**Image Representation:
Find the length of the string
**Example:
Dart `
// Main function main() { // Declaring a string variable String gfg = "Geeks For Geeks";
// Finding the length int length = gfg.length;
// Printing the length of the string print(length); }
`
**Output:
15
**Explanation: The length of the string, including spaces in the above example, counts up to 15.
**Note: The length of the empty string is equal to 0.