【发布时间】:2021-09-14 09:38:38
【问题描述】:
基本上,有一排有两个容器,其中子容器作为单选按钮。容器根据选定的单选按钮更改颜色,但我希望容器通过点击它们而不是完全通过点击单选按钮来更改颜色。
代码:
Container(
height: 60,
width: 130,
decoration: BoxDecoration(
color: _radioBtnVal == 'manual' ? AMBER : WHITE,
borderRadius: BorderRadius.circular(15)),
child: Row(
children: [
Radio<String>(
//activeColor: WHITE,
activeColor: Colors.red,
value: "manual",
groupValue: _radioBtnVal,
onChanged: _handleChange),
Text(
"Manual",
style: TextStyle(
color: _radioBtnVal == 'manual' ? WHITE : BLACK,
fontWeight: FontWeight.bold),
),
],
),
),
SizedBox(width: 80),
Container(
height: 60,
width: 130,
decoration: BoxDecoration(
color: _radioBtnVal == 'video' ? AMBER : WHITE,
borderRadius: BorderRadius.circular(15)),
child: Row(
children: [
Radio<String>(
//activeColor: WHITE,
activeColor: Colors.red,
value: "video",
groupValue: _radioBtnVal,
onChanged: _handleChange),
Text(
"Video Call",
style: TextStyle(
color: _radioBtnVal == 'video' ? WHITE : BLACK,
fontWeight: FontWeight.bold),
),
],
),
),
这是输出的图像。
输出:
【问题讨论】:
标签: flutter