我正在为孩子们制作正确的拼写应用程序,当我点击给定选项时,它会按顺序添加到顶部文本中
我的尝试
Center(
child: Text(
imageList[anu1].wrongSpell1,
),
),
我想将此文本值添加到另一个 .单击此文本时,它将添加到变量中
var mytext;
我像这样在这个变量中添加我的文本
mytext = mytext.add(imageList[anu1].wrongSpell1);
setState(() {});
在这里显示我添加的文本
Text(
mytext.toString(),
)
答案 0 :(得分:1)
您所要做的就是“连接”字符串。
String mytext = 'starting text';
TextButton(
onPressed: () {
setState(() {
mytext = mytext + imageList[anu1].wrongSpell1;
});
},
child: Text(imageList[anu1].wrongSpell1),
)
//// here is where you would show your text:
Text(mytext)
答案 1 :(得分:1)
您需要做的就是:
String myname = 'ottoman';
setState(() {
myname = myname + imageList[anu1].wrongSpell1;
});