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
Which Flutter widget is commonly used to detect taps? a) GestureDetector b) InkWell c) Both a and b d) Button
The onPanUpdate callback in a GestureDetector is used for: a) Handling taps b) Tracking drag movements c) Responding to swipes d) Zoom interactions
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
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
Which widget is preferred for providing ripple effects with gesture detection? a) GestureDetector b) InkResponse c) InkWell d) ListTile
TextField and Form Validation
What property in TextField is used to handle text changes? a) onSubmit b) onEditingComplete c) onChanged d) textInputAction
To validate a form in Flutter, you typically use: a) Text widget b) Form and GlobalKey<FormState> c) GestureDetector d) StateBuilder
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
Which Flutter widget is used to group multiple input fields for validation? a) Column b) Container c) Form d) ListView
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
Which widget is used to create a toggleable switch? a) Slider b) Checkbox c) Switch d) ToggleButton
What property of Slider defines its minimum value? a) minValue b) min c) lowerBound d) startValue
The Checkbox widget requires which property to determine its state? a) value b) selected c) isChecked d) state
Which callback is triggered when the Switch widget changes state? a) onSwitch b) onChanged c) onToggle d) onUpdate
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
Which widget manages focus in Flutter? a) FocusNode b) FocusManager c) TextField d) FocusScope
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
The FocusNode class is used to: a) Validate forms b) Manage and control focus c) Capture keyboard input d) Display error messages
Which widget wraps a TextField to move focus to the next field on submit? a) GestureDetector b) AutofillGroup c) FocusTraversalGroup d) FocusScope
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
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
Which property of TextField controls the keyboard type? a) keyboardAppearance b) inputType c) keyboardType d) textInputAction
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
Which widget is ideal for creating numeric sliders in Flutter? a) RangeSlider b) NumericSlider c) Slider d) NumberField
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
What is FocusScopeNode used for? a) Managing focus across the app b) Detecting gestures c) Handling form validation d) Switching themes
The keyboardType property in TextField is an instance of: a) InputDecoration b) TextInputType c) TextStyle d) InputController
To display a checkbox list, you typically use: a) ListView with CheckBox widgets b) DropdownButton c) PopupMenuButton d) ExpansionTile
Which widget can handle both text input and focus? a) TextFormField b) Text c) Form d) Column
A FocusNode must be disposed of to: a) Release resources b) Enable validation c) Add more focusable elements d) Set keyboard actions