KitCheckBox class
create_user: zhengzaihong email:1096877329@qq.com create_date: 2022/11/18 create_time: 10:29 describe: 复选框组件 / Checkbox Component
支持系统默认样式和完全自定义样式的复选框 Supports both system default style and fully customizable style
功能特性 / Features
- ✅ 支持系统默认样式 / System default style
- 🎨 支持完全自定义图标 / Fully custom icons
- 📍 支持图标左右位置 / Icon position (left/right)
- 📝 支持选中/未选中不同文本 / Different text for checked/unchecked
- 🎯 支持初始化回调 / Initial callback support
- 📏 支持缩放 / Scale support
基础示例 / Basic Example
// 系统默认样式
KitCheckBox(
text: Text("同意协议"),
isChecked: false,
onChange: (checked) {
print('选中状态: $checked');
},
)
// 自定义样式
KitCheckBox(
useDefaultStyle: false,
text: Text("记住密码"),
checkIcon: Icon(Icons.check_box, color: Colors.blue),
uncheckedIcon: Icon(Icons.check_box_outline_blank, color: Colors.grey),
isChecked: true,
onChange: (checked) => print(checked),
)
// 图标在左侧
KitCheckBox(
iconLeft: true,
text: Text("接收通知"),
activeColor: Colors.green,
onChange: (checked) => print(checked),
)
// 不同的选中/未选中文本
KitCheckBox(
text: Text("未选中"),
checkedText: Text("已选中", style: TextStyle(color: Colors.blue)),
onChange: (checked) => print(checked),
)
// 自定义缩放
KitCheckBox(
scale: 1.5,
text: Text("大号复选框"),
activeColor: Colors.purple,
onChange: (checked) => print(checked),
)
注意事项 / Notes
- useDefaultStyle 为 true 时使用系统样式 / Use system style when true
- useDefaultStyle 为 false 时必须提供 checkIcon 和 uncheckedIcon / Must provide icons when false
- enableFirstCallBack 为 true 时会在初始化时触发回调 / Triggers callback on init when true
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- KitCheckBox
- Available extensions
Constructors
-
KitCheckBox({Widget? text, Widget? checkedText, Widget? uncheckedIcon, Widget? checkIcon, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, MainAxisSize mainAxisSize = MainAxisSize.min, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center, bool? useDefaultStyle = true, bool? iconLeft = false, bool? isChecked = false, dynamic onChange(bool value)?, bool enableFirstCallBack = false, Color? activeColor, Color? checkColor, double? scale = 1, WidgetStateProperty<
Color?> ? fillColor, BorderSide? side, double? splashRadius, Key? key}) -
const
Properties
- activeColor → Color?
-
选中时的颜色 / Active color
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
final
- checkColor → Color?
-
勾选标记颜色 / Check mark color
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
final
- checkedText → Widget?
-
选中时的文本 / Text when checked
如果为 null 则使用 text / Uses text if null
final
- checkIcon → Widget?
-
选中时的图标 / Icon when checked
useDefaultStyle 为 false 时必填 / Required when useDefaultStyle is false
final
- crossAxisAlignment → CrossAxisAlignment
-
交叉轴对齐方式 / Cross axis alignment
默认值: CrossAxisAlignment.center / Default: CrossAxisAlignment.center
final
- enableFirstCallBack → bool
-
是否在初始化时触发回调 / Enable first callback
默认值: false / Default: false
final
-
fillColor
→ WidgetStateProperty<
Color?> ? -
填充颜色 / Fill color
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iconLeft → bool?
-
图标是否在左侧 / Icon on left side
默认值: false (右侧) / Default: false (right side)
final
- isChecked → bool?
-
是否选中 / Is checked
默认值: false / Default: false
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mainAxisAlignment → MainAxisAlignment
-
主轴对齐方式 / Main axis alignment
默认值: MainAxisAlignment.start / Default: MainAxisAlignment.start
final
- mainAxisSize → MainAxisSize
-
主轴大小 / Main axis size
默认值: MainAxisSize.min / Default: MainAxisSize.min
final
- onChange → dynamic Function(bool value)?
-
状态改变回调 / Change callback
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double?
-
缩放比例 / Scale
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
默认值: 1.0 / Default: 1.0
final
- side → BorderSide?
-
边框样式 / Border side
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
final
- splashRadius → double?
-
水波纹半径 / Splash radius
仅在 useDefaultStyle 为 true 时生效 / Only works when useDefaultStyle is true
final
- text → Widget?
-
未选中时的文本 / Text when unchecked
final
- uncheckedIcon → Widget?
-
未选中时的图标 / Icon when unchecked
useDefaultStyle 为 false 时必填 / Required when useDefaultStyle is false
final
- useDefaultStyle → bool?
-
是否使用系统默认样式 / Use default system style
true: 系统样式 / System style
false: 自定义样式 / Custom style
默认值: true / Default: true
final
Methods
-
blurred(
{double blur = 5, Color blurColor = Colors.white, BorderRadius? borderRadius, double colorOpacity = 0.5, Widget? overlay, AlignmentGeometry alignment = Alignment.center}) → Blur -
Available on Widget, provided by the BlurExtension extension
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< KitCheckBox> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
frosted(
{double blur = 5, Color frostColor = Colors.white, AlignmentGeometry alignment = Alignment.center, double? height, double? width, double frostOpacity = 0.0, BorderRadius? borderRadius, EdgeInsetsGeometry padding = EdgeInsets.zero}) → Blur -
Available on Widget, provided by the FrostExtension extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited