MCQs on Working with User Input & Forms | Flutter User Input MCQs Question and Answer

Flutter offers a powerful toolkit to build user-friendly forms and handle various input methods. From managing gestures like taps and swipes to handling form validation with TextField, Flutter simplifies input widgets such as sliders, switches, and checkboxes. Explore these multiple-choice questions to strengthen your understanding of user input handling in Flutter.


Handling Gestures: Taps, Drags, and Swipes

  1. Which Flutter widget is commonly used to detect taps?
    a) GestureDetector
    b) InkWell
    c) Both a and b
    d) Button
  2. The onPanUpdate callback in a GestureDetector is used for:
    a) Handling taps
    b) Tracking drag movements
    c) Responding to swipes
    d) Zoom interactions
  3. How can a double-tap gesture be detected in Flutter?
    a) Use onDoubleTap in GestureDetector
    b) Use onTapDown twice
    c) Implement onSwipe callback
    d) Use onLongPress
  4. What does the onHorizontalDragEnd event in a GestureDetector detect?
    a) Tap completion
    b) Dragging horizontally to an endpoint
    c) Swiping left or right
    d) Multi-touch gestures
  5. Which widget is preferred for providing ripple effects with gesture detection?
    a) GestureDetector
    b) InkResponse
    c) InkWell
    d) ListTile

TextField and Form Validation

  1. What property in TextField is used to handle text changes?
    a) onSubmit
    b) onEditingComplete
    c) onChanged
    d) textInputAction
  2. To validate a form in Flutter, you typically use:
    a) Text widget
    b) Form and GlobalKey<FormState>
    c) GestureDetector
    d) StateBuilder
  3. The validator property in a FormField returns:
    a) A boolean value
    b) An error message string or null
    c) Always null
    d) A focus node
  4. Which Flutter widget is used to group multiple input fields for validation?
    a) Column
    b) Container
    c) Form
    d) ListView
  5. In TextField, the obscureText property is primarily used for:
    a) Masking sensitive input like passwords
    b) Enabling multi-line text input
    c) Hiding the cursor
    d) Disabling the text field

Input Widgets: Sliders, Switches, and Checkboxes

  1. Which widget is used to create a toggleable switch?
    a) Slider
    b) Checkbox
    c) Switch
    d) ToggleButton
  2. What property of Slider defines its minimum value?
    a) minValue
    b) min
    c) lowerBound
    d) startValue
  3. The Checkbox widget requires which property to determine its state?
    a) value
    b) selected
    c) isChecked
    d) state
  4. Which callback is triggered when the Switch widget changes state?
    a) onSwitch
    b) onChanged
    c) onToggle
    d) onUpdate
  5. How do you create a range slider in Flutter?
    a) Use SliderRange widget
    b) Use RangeSlider widget
    c) Combine two Slider widgets
    d) Use MultiSlider widget

Keyboard Handling and Focus Management

  1. Which widget manages focus in Flutter?
    a) FocusNode
    b) FocusManager
    c) TextField
    d) FocusScope
  2. How do you dismiss the keyboard programmatically in Flutter?
    a) Call FocusScope.of(context).unfocus()
    b) Use Keyboard.dismiss()
    c) Set keyboardVisibility to false
    d) Disable the TextField
  3. The FocusNode class is used to:
    a) Validate forms
    b) Manage and control focus
    c) Capture keyboard input
    d) Display error messages
  4. Which widget wraps a TextField to move focus to the next field on submit?
    a) GestureDetector
    b) AutofillGroup
    c) FocusTraversalGroup
    d) FocusScope
  5. The onEditingComplete callback in TextField is triggered when:
    a) The user stops typing
    b) The user presses the “Done” button
    c) The focus changes
    d) Validation completes

Miscellaneous

  1. What is the primary method to implement a custom input gesture in Flutter?
    a) Create a custom widget
    b) Use GestureDetector callbacks
    c) Modify existing input widgets
    d) Use InputFormatter
  2. Which property of TextField controls the keyboard type?
    a) keyboardAppearance
    b) inputType
    c) keyboardType
    d) textInputAction
  3. A FormField is different from TextField because it:
    a) Is not interactive
    b) Supports validation by default
    c) Cannot be styled
    d) Does not support focus management
  4. Which widget is ideal for creating numeric sliders in Flutter?
    a) RangeSlider
    b) NumericSlider
    c) Slider
    d) NumberField
  5. onChanged in a Slider is called:
    a) When the slider is initially rendered
    b) Whenever the slider thumb moves
    c) After the thumb movement is complete
    d) Only on long presses
  6. What is FocusScopeNode used for?
    a) Managing focus across the app
    b) Detecting gestures
    c) Handling form validation
    d) Switching themes
  7. The keyboardType property in TextField is an instance of:
    a) InputDecoration
    b) TextInputType
    c) TextStyle
    d) InputController
  8. To display a checkbox list, you typically use:
    a) ListView with CheckBox widgets
    b) DropdownButton
    c) PopupMenuButton
    d) ExpansionTile
  9. Which widget can handle both text input and focus?
    a) TextFormField
    b) Text
    c) Form
    d) Column
  10. A FocusNode must be disposed of to:
    a) Release resources
    b) Enable validation
    c) Add more focusable elements
    d) Set keyboard actions

Answer Key

QnoAnswer
1c) Both a and b
2b) Tracking drag movements
3a) Use onDoubleTap in GestureDetector
4b) Dragging horizontally to an endpoint
5c) InkWell
6c) onChanged
7b) Form and GlobalKey<FormState>
8b) An error message string or null
9c) Form
10a) Masking sensitive input like passwords
11c) Switch
12b) min
13a) value
14b) onChanged
15b) Use RangeSlider widget
16a) FocusNode
17a) Call FocusScope.of(context).unfocus()
18b) Manage and control focus
19d) FocusScope
20b) The user presses the “Done” button
21b) Use GestureDetector callbacks
22c) keyboardType
23b) Supports validation by default
24c) Slider
25b) Whenever the slider thumb moves
26a) Managing focus across the app
27b) TextInputType
28a) ListView with CheckBox widgets
29a) TextFormField
30a) Release resources

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top