ShadCheckbox class
A customizable checkbox widget with optional label and sublabel.
The ShadCheckbox widget allows users to toggle a boolean state, visually represented by a checkmark within a styled box. It supports enabling/disabling, focus handling, animations, and integrates with ShadTheme for consistent styling.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ShadCheckbox
- Available extensions
Constructors
-
ShadCheckbox({Key? key, required bool value, bool enabled = true, ValueChanged<
bool> ? onChanged, FocusNode? focusNode, ShadDecoration? decoration, double? size, Duration? duration, Widget? icon, Color? color, Color? uncheckedColor, Widget? label, Widget? sublabel, EdgeInsetsGeometry? padding, TextDirection? direction, CrossAxisAlignment? crossAxisAlignment, EdgeInsetsGeometry? checkboxPadding}) -
Creates a checkbox widget with the specified state and options.
const
Properties
- checkboxPadding → EdgeInsetsGeometry?
-
The padding around the checkbox field only.
final
- color → Color?
-
The color of the checkbox when checked.
Defaults to the theme’s primary color if not specified.
final
- crossAxisAlignment → CrossAxisAlignment?
-
The cross-axis alignment of the checkbox and label/sublabel.
Defaults to CrossAxisAlignment.start if both label and sublabel are
present, otherwise CrossAxisAlignment.center.
final
- decoration → ShadDecoration?
-
The decoration applied to the checkbox box.
Merged with the theme’s default decoration if provided.
final
- direction → TextDirection?
-
The text direction for arranging the checkbox and label/sublabel.
Defaults to null (inherits from context) if not specified.
final
- duration → Duration?
-
The duration of the checkmark animation when toggling.
Defaults to 100 milliseconds if not specified.
final
- enabled → bool
-
Whether the checkbox is interactive.
Defaults to true; if false, the checkbox is disabled and visually dimmed.
final
- focusNode → FocusNode?
-
The focus node for keyboard navigation and focus handling.
If null, an internal focus node is created.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
The icon displayed when the checkbox is checked.
Defaults to a checkmark icon if not specified.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → Widget?
-
An optional label displayed next to the checkbox.
Typically a Text widget, positioned based on direction.
final
-
onChanged
→ ValueChanged<
bool> ? -
Callback invoked when the checkbox is toggled.
If null, the checkbox is non-interactive but still visible.
final
- padding → EdgeInsetsGeometry?
-
The padding between the checkbox and its label/sublabel.
Defaults to
EdgeInsetsDirectional.only(start: 8)if not specified.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → double?
-
The size (width and height) of the checkbox box.
Defaults to 16 if not specified.
final
- sublabel → Widget?
-
An optional sublabel displayed below the label.
Typically a Text widget, enhancing the checkbox description.
final
- uncheckedColor → Color?
-
The color of the checkbox when unchecked.
Defaults to the theme’s input color if not specified.
final
- value → bool
-
Whether the checkbox is checked (true) or unchecked (false).
Required to set the initial state of the checkbox.
final
Methods
-
animate(
{Key? key, List< Effect> ? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) → Animate -
Available on Widget, provided by the AnimateWidgetExtensions extension
Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex.myWidget.animate()is equivalent toAnimate(child: myWidget). -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ShadCheckbox> -
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
positionedWith(
ShadPosition position) → Widget -
Available on Widget, provided by the PositionedExt extension
-
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