I would like to access an index of a string (e.g. 'Hello') and print it to the app (e.g. letter 'o'). This string has to be the input of the user. This can be easily done using Python but I have to use Flutter/Dart in order to do it (mobile development).

Here is just an example of how this would be solve using Python:

my_word = input("Insert your word here: ")

print(my_word[4])


Solution 1: esentis

You can try split the string's letters in an array first.

my_word.split('')[4]


Solution 2: Yeasin Sheikh

dartPad

main() {
  String val = "hello";
  print(val[4]);
}


Solution 3: Stewie Griffin

  1. Use TextField to retrieve user's input:

A text field lets the user enter text, either with hardware keyboard or with an onscreen keyboard.

  1. Use Text to display the string that you retrieve:

The Text widget displays a string of text with single style.

  1. Use the [] (index) operator to get the character at the index you specify:
final str = "Hello World";

print(str[4]); // Prints o