0
0
Fluttermobile~10 mins

Radio buttons 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 radio button with value 1.

Flutter
Radio<int>(value: [1], groupValue: selectedValue, onChanged: (int? val) { setState(() { selectedValue = val!; }); })
Drag options to blanks, or click blank then click option'
A1
Btrue
C0
D"one"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer for the value.
Setting value to true or false instead of a number.
2fill in blank
medium

Complete the code to update the selected radio button value inside onChanged.

Flutter
onChanged: (int? val) { setState(() { selectedValue = [1]; }); }
Drag options to blanks, or click blank then click option'
Aval!
B1
CselectedValue
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a fixed number instead of the passed value.
Forgetting to unwrap the nullable value.
3fill in blank
hard

Fix the error in the code by completing the missing property to show the selected radio button.

Flutter
Radio<int>(value: 2, groupValue: [1], onChanged: onChanged)
Drag options to blanks, or click blank then click option'
AonChanged
BselectedValue
Cnull
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Setting groupValue to a fixed number instead of the state variable.
Setting groupValue to null or the onChanged function.
4fill in blank
hard

Fill both blanks to create a group of two radio buttons with values 1 and 2.

Flutter
Column(children: [Radio<int>(value: [1], groupValue: selectedValue, onChanged: onChanged), Radio<int>(value: [2], groupValue: selectedValue, onChanged: onChanged)])
Drag options to blanks, or click blank then click option'
A1
B2
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same value for both radio buttons.
Using values outside the expected range.
5fill in blank
hard

Fill all three blanks to create a radio button with label and update state on change.

Flutter
ListTile(title: Text([1]), leading: Radio<int>(value: [2], groupValue: selectedValue, onChanged: (int? val) { setState(() { selectedValue = [3]; }); }))
Drag options to blanks, or click blank then click option'
A"Option 1"
B1
Cval!
D"Choice"
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched values between label and radio button.
Not updating the state with the passed value.