【发布时间】:2021-08-09 20:00:14
【问题描述】:
你好,我想用 value = 'einmal' 更改索引上的列表颜色
小部件 _buildChoice() { 返回容器( 高度:MediaQuery.of(context).size.height/4,
child: ListView.builder(
itemCount: _choices.length,
itemBuilder: (BuildContext context, int index) {
return RaisedButton(
child: new Text(_choices[index]),
textColor: Colors.white,
// 2
color: _hasBeenPressed ? Colors.green : Colors.red,
// 3
onPressed: () => {
setState(() {
if(_choices[index] == 'einmal') {
_hasBeenPressed = !_hasBeenPressed;
}
})
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)
),
);
}
)
);}
【问题讨论】:
标签: flutter