0
0
Fluttermobile~10 mins

Checkbox and Switch in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Checkbox widget with a boolean value.

Flutter
Checkbox(value: [1], onChanged: (bool? newValue) { setState(() { isChecked = newValue!; }); })
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cnull
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using null instead of a boolean value.
Using numbers like 0 or 1 instead of true/false.
2fill in blank
medium

Complete the code to create a Switch widget that toggles a boolean state.

Flutter
Switch(value: isSwitched, onChanged: (bool [1]) { setState(() { isSwitched = [1]; }); })
Drag options to blanks, or click blank then click option'
Avalue
Bflag
Cstate
DnewValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name that does not match the variable inside the callback.
Using a non-boolean parameter name.
3fill in blank
hard

Complete the code to create a disabled indeterminate Checkbox widget.

Flutter
Checkbox(value: [1], onChanged: null)
Drag options to blanks, or click blank then click option'
A0
Btrue
Cnull
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using true or false, which shows checked or unchecked instead of indeterminate.
Using 0 instead of null.
4fill in blank
hard

Fill both blanks to create a CheckboxListTile with a title and a checked value.

Flutter
CheckboxListTile(title: Text([1]), value: [2], onChanged: (bool? val) { setState(() { isSelected = val!; }); })
Drag options to blanks, or click blank then click option'
A"Accept Terms"
Btrue
Cfalse
D"Enable Notifications"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting title without quotes or Text widget.
Using a string for value instead of boolean.
5fill in blank
hard

Fill all three blanks to create a SwitchListTile with a label, value, and onChanged callback.

Flutter
SwitchListTile(title: Text([1]), value: [2], onChanged: (bool [3]) { setState(() { isOn = [3]; }); })
Drag options to blanks, or click blank then click option'
A"Dark Mode"
BisDarkMode
CnewValue
D"Light Mode"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string for value instead of a boolean variable.
Mismatch between parameter name and variable inside onChanged.