Checkbox class
A checkbox for an independent boolean choice, usually confirmed later by a form submit.
Checkbox(
value: _agree,
onChanged: (v) => setState(() => _agree = v),
label: const Text('I agree'),
)
For a setting that takes effect immediately, prefer a Switch instead. For picking several values from a list, see CheckboxGroup.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Checkbox
Constructors
-
Checkbox({Key? key, bool? checked, bool? defaultChecked, ValueChanged<
bool> ? onChanged, Widget? label, bool? disabled, bool readOnly = false, String? semanticsLabel, InputStatus? status, ControlSize? size, bool indeterminate = false, CheckboxToken? token, FocusNode? focusNode, bool autofocus = false}) -
Creates a Checkbox.
const
Properties
- autofocus → bool
-
Whether the box takes focus as soon as it is built.
final
- checked → bool?
-
Whether the box is ticked.
final
- defaultChecked → bool?
-
Whether an uncontrolled box starts ticked. Defaults to false.
final
- disabled → bool?
-
Greys the checkbox out and blocks toggling.
final
- focusNode → FocusNode?
-
A focus node of your own, for a box whose focus you drive yourself.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- indeterminate → bool
-
Shows a dash rather than a tick — the "some but not all" state of a
parent checkbox. Toggling still reports the opposite of checked.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → Widget?
-
The label widget beside the box.
final
-
onChanged
→ ValueChanged<
bool> ? -
Called with the new state when toggled.
final
- readOnly → bool
-
Shows whether it is ticked without letting anyone change it.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticsLabel → String?
-
What a screen reader calls this box, in place of the words beside it.
final
- size → ControlSize?
-
How big the box and its words are: a preset, or the box's side in
pixels.
final
- status → InputStatus?
-
Recolours the box's edge to say the answer is wanting: red for
InputStatus.error, amber for InputStatus.warning. A form's field
hands its own here, as it does to an input's border.
final
- token → CheckboxToken?
-
Per-instance token overrides.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< Checkbox> -
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
-
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