Learn/Forms & Input/Dropdown & Selection Widgets

Dropdown & Selection Widgets

Handle user selection from options

5 min~4 min read+30 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Choosing The Right Selection Control
  2. 2. This Lesson In Simple Words
  3. 3. Your level focus
  4. 4. One practical habit
  5. 5. Deep Understanding Guide
  6. 6. Why this lesson matters
  7. 7. Study flow for better retention
  8. 8. Quick Glossary

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Selection Widgets

Flutter provides several widgets for letting users pick from a set of options. Checkboxes handle simple on/off choices, radio buttons let users pick one item from a small group, and dropdown menus work best when there are many options to choose from. Each widget follows the same pattern of holding the current value in state and updating it through an onChanged callback.

dart
1// DropdownButton
2String? selectedCountry;
3
4DropdownButtonFormField<String>(
5 value: selectedCountry,
6 decoration: InputDecoration(
7 labelText: 'Country',
8 border: OutlineInputBorder(),
9 ),
10 items: ['USA', 'UK', 'Canada', 'Australia']
11 .map((country) => DropdownMenuItem(
12 value: country,
13 child: Text(country),
14 ))
15 .toList(),
16 onChanged: (value) {
17 setState(() {
18 selectedCountry = value;
19 });
20 },
21 validator: (value) => value == null ? 'Please select a country' : null,
22)
dart
1// Checkbox
2bool agreeToTerms = false;
3
4CheckboxListTile(
5 title: Text('I agree to the terms'),
6 value: agreeToTerms,
7 onChanged: (value) {
8 setState(() {
9 agreeToTerms = value ?? false;
10 });
11 },
12)
13
14// Radio buttons
15String? selectedGender;
16
17Column(
18 children: ['Male', 'Female', 'Other'].map((gender) {
19 return RadioListTile<String>(
20 title: Text(gender),
21 value: gender,
22 groupValue: selectedGender,
23 onChanged: (value) {
24 setState(() {
25 selectedGender = value;
26 });
27 },
28 );
29 }).toList(),
30)

Choosing The Right Selection Control

Use control type based on decision complexity:

  • Checkbox for independent yes/no toggles
  • Radio for one choice among a small visible set
  • Dropdown for one choice from a longer list

Control choice directly affects speed, clarity, and error rate in user decisions.

Selection UX Checklist

  • Default selection behavior is intentional and safe.
  • Labels are unambiguous and short.
  • Validation clearly explains what is missing.
  • Selected state is visible and accessible to assistive tech.

This Lesson In Simple Words

Handle user selection from options. Widgets are reusable UI blocks. You combine them like LEGO pieces to build screens.

Your level focus

Connect each concept to real app features you can build.

One practical habit

Sketch the widget tree first, then code from top to bottom.

Deep Understanding Guide

Why this lesson matters

Most Flutter productivity comes from understanding layout rules and composing widgets cleanly.

Study flow for better retention

  1. Map the lesson to one screen, one user action, and one expected output.
  2. When a UI bug appears, inspect constraints and parent-child relations before changing random values.
  3. If you can choose between two approaches and explain why, you are improving.

Common Mistakes To Avoid

  • Nesting too many widgets without extracting reusable pieces.
  • Ignoring constraints and guessing with random SizedBox heights.
  • Using one giant build method for unrelated UI sections.
  • Putting heavy calculations directly in build methods.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one card layout with Row/Column and rebuild it using Stack for comparison.
  • Split a large widget into 3 smaller widgets with clear responsibilities.
  • Use const constructors where possible and observe rebuild behavior.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What property groups RadioListTile buttons together?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • state: Data that can change and update what the user sees.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Dropdown & Selection Widgets" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Nesting too many widgets without extracting reusable pieces.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

What property groups RadioListTile buttons together?

groupValue determines which radio button is selected in the group.

How do you show a dropdown with form validation?

DropdownButtonFormField integrates with Form widget for validation, unlike plain DropdownButton.

What does CheckboxListTile combine?

CheckboxListTile combines a Checkbox with a ListTile for a label, making it convenient for settings.

What happens when onChanged is null on a dropdown?

Setting onChanged to null disables the dropdown, making it non-interactive.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue