使用现有答案作为提示文本
我正在尝试显示存储在列表 List中的现有答案data = [];
作为提示文本(如果可用)。目前我正在使用这个代码:https://pastecode.io/s/bj9jkx06
错误是,如果我回答第二个问题,提示文本将显示在第一个文本字段中。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为数据对象不是必需的。关键就是问题,就像你其他人的地图一样。
我会简单地使用另一个映射
这需要对 read 方法内的数据加载进行如下更改:
现在您的数据已加载,您可以使用问题作为键以这种方式检索问题的提示:
如果数据不包含与以下内容相关的记录一个具体的问题,它会返回“写一些东西”字符串
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.
This requires the data loading inside the read method to be changed as follows:
Now that your data are loaded, you can retrive the hint for the question in this way, using the question as the key:
If data doesn't contains record related to a specific question, it will return 'write something' string
尝试在hintText的InputDecoration属性上提供TextField,它需要一个像这样的字符串
Try to give the TextField on the InputDecoration property of hintText it takes a string like
只是提醒您,
索引从 0 开始
。所以你落后了一个textfield
。just to remind you,
index starts with 0
. So you are getting onetextfield
behind.