Checkbox
The C2CCheckbox widget allows you to create interactive checkboxes with options for customizing labels, error messages, and appearance. You can control the checkbox's state, whether it's checked, indeterminate, or disabled.
Installation
cpub add c2c_checkbox
or
flutter pub add c2c_checkbox --hosted-url=https://pub.csp.scrum-dev.com
Example Usage
To use the C2CCheckbox widget, you can create an instance of it and provide the necessary parameters:
C2CCheckbox(
label: 'Accept Terms & Conditions',
checked: true,
onChanged: (value) {
// Handle checkbox state change
},
error: 'Please accept the terms & conditions.',
// Add more customization options as needed
)
Properties
Here are the properties available for customizing the C2CCheckbox widget:
| Property | Description | Type |
|---|---|---|
label | Label text. It can be a [String] or a [Widget]. | dynamic |
labelTextStyle | Label text style. | TextStyle? |
checked | Whether the checkbox is checked. | bool |
indeterminate | Whether the checkbox is indeterminate. | bool |
disabled | Whether the checkbox is disabled. | bool |
onChanged | Called when the checkbox is changed. | void Function(bool)? |
error | Error text. It can be a [String] or a [Widget]. | dynamic |
errorTextStyle | Error text style. | TextStyle? |
description | Description text. It can be a [String] or a [Widget]. | dynamic |
descriptionTextStyle | Description text style. | TextStyle? |
errorTextSpacing | Spacing between error text and label. | double? |
labelSpacingLeft | Spacing between label and checkbox. | double? |
checkColor | Color of the check icon. | Color? |
backgroundColor | Color of the background. | Color? |
borderSide | Border side of the checkbox. | BorderSide? |
activeBackgroundColor | Color of the background when the checkbox is active. | Color? |
activeBorderSide | Border side of the checkbox when the checkbox is active. | BorderSide? |
disabledBackgroundColor | Color of the background when the checkbox is disabled. | Color? |
disabledBorderSide | Border side of the checkbox when the checkbox is disabled. | BorderSide? |
errorBackgroundColor | Color of the background when the checkbox has an error. | Color? |
errorBorderSide | Border side of the checkbox when the checkbox has an error. | BorderSide? |
inverse | Whether the checkbox is inverse. | bool? |
borderRadius | Border radius of the checkbox. | double? |
viewOnly | Whether the checkbox is view only. | bool |
checkboxSize | Size of the checkbox. | double? |
errorShadow | Shadow of the checkbox when the checkbox has an error. | BoxShadow? |
showErrorMessage | Whether to show the error message. | bool |