Google Flutter Google Flutter Widgets 1 — Questions and Answers
Question 1: Which widget in Flutter is used to arrange children in a horizontal line?
- Column
- Stack
- Row (Correct answer)
- Wrap
Correct answer: Row
Row lays out its children in a horizontal array along the main axis.
Question 2: What does the Expanded widget do inside a Row or Column?
- Adds padding around a child
- Makes a child scroll
- Forces a child to fill the remaining available space along the main axis (Correct answer)
- Centers a child widget
Correct answer: Forces a child to fill the remaining available space along the main axis
Expanded wraps a child and causes it to expand to fill available space along the main axis of a Row or Column.
Question 3: Which widget creates a scrollable list of widgets that are all constructed at once?
- ListView.builder
- ListView (Correct answer)
- GridView
- SingleChildScrollView
Correct answer: ListView
ListView (without a builder) constructs all its children eagerly and wraps them in a scrollable container.
Question 4: What is the purpose of the SizedBox widget?
- To clip its child to a rounded rectangle
- To provide a fixed-size box or to add whitespace between widgets (Correct answer)
- To add a border to a widget
- To handle gestures
Correct answer: To provide a fixed-size box or to add whitespace between widgets
SizedBox constrains its child to a specific width and height, and is also used as an empty spacer widget.
Question 5: Which widget allows you to position children at arbitrary locations within a parent?
- Column
- Row
- Stack (Correct answer)
- Wrap
Correct answer: Stack
Stack layers its children on top of each other, and Positioned can be used to place them at specific coordinates.
Question 6: What does the GestureDetector widget do in Flutter?
- Detects device sensors
- Wraps a widget to detect touch gestures like tap, drag, and long press (Correct answer)
- Plays haptic feedback
- Draws gesture trails on the screen
Correct answer: Wraps a widget to detect touch gestures like tap, drag, and long press
GestureDetector is an invisible widget that detects touch gestures and fires callbacks like onTap and onPanUpdate.
Which widget in Flutter is used to arrange children in a horizontal line?