【发布时间】:2026-01-14 17:40:01
【问题描述】:
【问题讨论】:
-
是的,它可以工作,但我想使用单选按钮小部件
标签: flutter dart flutter-layout
【问题讨论】:
标签: flutter dart flutter-layout
你可以试试这个方法:
int _value = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
children: <Widget>[
GestureDetector(
onTap: () => setState(() => _value = 0),
child: Container(
height: 56,
width: 56,
color: _value == 0 ? Colors.grey : Colors.transparent,
child: Icon(Icons.call),
),
),
SizedBox(width: 4),
GestureDetector(
onTap: () => setState(() => _value = 1),
child: Container(
height: 56,
width: 56,
color: _value == 1 ? Colors.grey : Colors.transparent,
child: Icon(Icons.message),
),
),
],
),
),
);
}
【讨论】:
RadioButton 小部件,您的意思是简单的Radio 还是RadioListTile?
RadioListTile 的新答案。