San*_*inh 5 dart flutter flutter-layout
我想在 Flutter/Dart 中创建这样的 RadioListTile。我尝试过但没有成功。
当用户选择性别时,所选按钮应显示为灰色背景的白色图标
Cop*_*oad 10
你可以试试这个方法:
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),
),
),
],
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5790 次 |
最近记录: |