'Using existing answer as a hint text

i'm trying to display the existing answers that are stored in the list List<Data> data = []; as a hint text if they're available. currently i'm using this code: https://pastecode.io/s/bj9jkx06

the error is that if i answer the question number two, the hint text will show in the textfield number one.

enter image description here



Solution 1:[1]

I think the Data object is not required. I would simply use another map<String, String> where the key is the question, exactly as your others maps.

Map<String, String> data = {}

This requires the data loading inside the read method to be changed as follows:

raw.forEach((key, value) {
   data[key] = value;
});

Now that your data are loaded, you can retrive the hint for the question in this way, using the question as the key:

String hint = data[question] != null? data[question] : 'write something';

If data doesn't contains record related to a specific question, it will return 'write something' string

Solution 2:[2]

Try to give the TextField on the InputDecoration property of hintText it takes a string like

hintText: "Hint Text"

Solution 3:[3]

just to remind you, index starts with 0. So you are getting one textfield behind.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 L. Gangemi
Solution 2 Badrelden Ahmed
Solution 3 vector