Skip to content
On this page

Checkbox 复选框

代码演示

基本用法

dart
Checkbox(
  label: "复选框",
  checked: true,
  onChange: (checked) => {},
),

禁用状态

dart
Checkbox(label: "复选框", disabled: true),

形状

dart
Checkbox(shape: BoxShape.rectangle, checked: true),

颜色

dart
Checkbox(checkedColor: Color(0xFFEE0A24), checked: true),

图标

dart
Checkbox(
  checked: true,
  icon: (checked) {
    final icon = checked //
        ? Icons.visibility
        : Icons.visibility_off;
    return FittedBox(child: Icon(icon));
  },
),

API

Props类型描述
valuebool当前已选
onChangeFunction(bool)值变化触发
shapeBoxShape选框形状
iconWidget Function(bool checked)选框图标
label(Widget | String | null) Function(bool checked) | Widget | String | null选框标题
disabledbool禁用状态
checkedColorColor已选颜色