Radio 单选框
代码演示
基本用法
dart
Radio(
checked: model.value,
onChange: (v) => model.value = v,
label: "单选框",
),
单选框组
dart
RadioGroup(
value: model.value,
onChange: (name) => model.value = name,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Radio(name: "1", label: "单选框 1"),
SizedBox(height: 10),
Radio(name: "2", label: "单选框 2"),
],
),
),
水平排列
dart
RadioGroup(
value: model.value,
onChange: (name) => model.value = name,
child: Row(children: const [
Radio(name: "1", label: "单选框 1"),
SizedBox(width: 10),
Radio(name: "2", label: "单选框 2"),
]),
),
API
Props | 类型 | 描述 |
---|---|---|
name | String | 单选框值 |
onChange | Function(bool) | 选择时触发 |
shape | BoxShape | 选框形状 |
icon | Widget Function(bool checked) | 选框图标 |
label | (Widget | String | null) Function(bool checked) | Widget | String | null | 选框标题 |
disabled | bool | 禁用状态 |
checkedColor | Color | 选中颜色 |