A. Row and Column are used incorrectly for screen sizes
B. Using Row for small screens may cause overflow horizontally
C. No error; code works fine for responsive layout
D. Missing MediaQuery to get screen size
Solution
Step 1: Analyze layout for small screens
For small screens, a Row with two Text widgets may overflow horizontally.
Step 2: Understand overflow risk
Row arranges children horizontally, which can cause overflow if width is limited.
Step 3: Check other options
MediaQuery is not required here; LayoutBuilder provides constraints. Using Column on large screens is fine.
Final Answer:
Using Row for small screens may cause overflow horizontally -> Option B
Quick Check:
Row on narrow screen risks overflow [OK]
Hint: Row on narrow screen can overflow horizontally [OK]
Common Mistakes:
Thinking code has no error
Believing MediaQuery is mandatory here
Confusing Row and Column usage
5. You want to create a responsive Flutter layout that shows a vertical list on narrow screens and a grid with 3 columns on wide screens. Which approach is best?
hard
A. Use a fixed Container size and ignore screen width
B. Use MediaQuery to get screen height and switch between ListView and GridView
C. Always use GridView with 3 columns regardless of screen size
D. Use LayoutBuilder to check maxWidth and return ListView or GridView accordingly
Solution
Step 1: Decide how to detect screen width
LayoutBuilder provides maxWidth constraints inside builder, ideal for responsive layout.
Step 2: Choose widgets based on width
Return ListView for narrow screens and GridView with 3 columns for wide screens.
Step 3: Evaluate other options
MediaQuery height is not relevant; fixed Container ignores responsiveness; always GridView ignores narrow screens.
Final Answer:
Use LayoutBuilder to check maxWidth and return ListView or GridView accordingly -> Option D