Complete the code to create a Checkbox widget with a boolean value.
Checkbox(value: [1], onChanged: (bool? newValue) { setState(() { isChecked = newValue!; }); })The Checkbox widget requires a boolean value for its value property. Here, false means the checkbox is initially unchecked.
Complete the code to create a Switch widget that toggles a boolean state.
Switch(value: isSwitched, onChanged: (bool [1]) { setState(() { isSwitched = [1]; }); })
The onChanged callback provides the new boolean value as a parameter. Naming it newValue is common and clear.
Complete the code to create a disabled indeterminate Checkbox widget.
Checkbox(value: [1], onChanged: null)Setting onChanged to null disables the Checkbox, so the value can be null to indicate the indeterminate state.
Fill both blanks to create a CheckboxListTile with a title and a checked value.
CheckboxListTile(title: Text([1]), value: [2], onChanged: (bool? val) { setState(() { isSelected = val!; }); })
The title should be a string inside Text widget, and value must be a boolean. Here, the checkbox starts unchecked with false.
Fill all three blanks to create a SwitchListTile with a label, value, and onChanged callback.
SwitchListTile(title: Text([1]), value: [2], onChanged: (bool [3]) { setState(() { isOn = [3]; }); })
The title is a string inside Text, value is a boolean variable, and the onChanged parameter name matches the variable used inside the callback.