我有清单:
List quotes = [
"Lmao this is text",
"Okay okay go to next",
"So, we are the champion nanana",
"Gagagagaga",
"What does the fox say?"
];
var _index = new Random();
我想从我的列表元素创建随机文本生成器。我在颤振中使用 statefull,当我点击按钮时,我想要列表中的新随机元素。我的代码示例:
children: [
Text(quotes[_index]),
Center(
child: Container(
child: FlatButton.icon(
onPressed: _showFate(),
icon: Icon(Icons.casino),
label: Text("New words!", style: TextStyle(
color: Colors.white
),)),
_showFate() {
setState(() {
_index.nextInt(5);
});
为什么它不起作用我不明白......