Skip to content
On this page

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类型描述
nameString单选框值
onChangeFunction(bool)选择时触发
shapeBoxShape选框形状
iconWidget Function(bool checked)选框图标
label(Widget | String | null) Function(bool checked) | Widget | String | null选框标题
disabledbool禁用状态
checkedColorColor选中颜色