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 | 类型 | 描述 |
---|---|---|
value | bool | 当前已选 |
onChange | Function(bool) | 值变化触发 |
shape | BoxShape | 选框形状 |
icon | Widget Function(bool checked) | 选框图标 |
label | (Widget | String | null) Function(bool checked) | Widget | String | null | 选框标题 |
disabled | bool | 禁用状态 |
checkedColor | Color | 已选颜色 |