by @kodeazy
flutter How to get last letter of string in dart file?
- In this blog we will discuss on how to get the the
last letter
of the string in flutter. - To get the
last letter
we have to identify thelength
of the string to fetch the last letter based on the index. - To get the
length
of theString
we havelength
function for aString
variable in dart. - As the
String
index starts from0
we have to takeString length -1
index to get the last letter of string. -
Below is example syntax.
print(example[example.length-1]);
-
Below is the sample program to get last letter of string based on index.
void main() { String example = "Testing"; print(example[example.length-1]); }
Output
g