【发布时间】:2021-03-07 18:07:54
【问题描述】:
我的 Flutter 代码有问题。 我想将 ListView _aAntwort() 作为 RaisedButton 中的文本调用。 在模拟中显示错误:“堆栈溢出”。 谁能帮帮我?
感谢您的大力支持:)
RaisedButton( //StatefulWidget
onPressed: () {},
child: _aAntwort(), //ERROR
),
Widget randAnswer() {
var list = <String>['aAnswer', 'bAnswer', 'cAnswer', 'dAnswer'];
var rand = new Random();
int i = rand.nextInt(list.length);
iAnswer = list[i];
list.removeAt(i);
int ii = rand.nextInt(list.length);
iiAnswer = list[ii];
list.removeAt(ii);
int iii = rand.nextInt(list.length);
iiiAnswer = list[iii];
list.removeAt(iii);
int iiii = rand.nextInt(list.length);
iiiiAnswer = list[iiii];
list.removeAt(iiii);
return randAnswer(); }
ListView _aAntwort() {
if (iAnswer == "aAnswer") {
return aAnswer();
} else if (iAnswer == "bAnswer") {
return bAnswer();
} else if (iAnswer == "cAnswer") {
return cAnswer();
} else if (iAnswer == "dAnswer") {
return dAnswer();
}
return _aAntwort(); } // I want to call this one
ListView aAnswer() {
return ListView.builder(
{.....
【问题讨论】:
-
你遇到了什么错误?
-
请再次尝试解释问题。
标签: android ios flutter listview dart