MCQs on Flutter Widgets Overview | Flutter Widgets MCQs Question and Answer

Explore Flutter widgets with this comprehensive collection of MCQs designed for developers and learners. Dive into concepts such as Stateless vs. Stateful widgets, common widgets like Text, Image, and Container, layout principles involving constraints, padding, and margins, and techniques for customizing widgets. Perfect your skills with these Flutter MCQ questions and answers!


Multiple Choice Questions (MCQs)

Stateless vs. Stateful Widgets

  1. What defines a Stateless widget in Flutter?
    a) It can change dynamically.
    b) It does not maintain state.
    c) It has a mutable state.
    d) It requires user interaction.
  2. Which class is the base for Stateful widgets in Flutter?
    a) StatelessWidget
    b) StatefulWidget
    c) WidgetBase
    d) StateWidget
  3. In which lifecycle method of a Stateful widget can you initialize data?
    a) build()
    b) dispose()
    c) initState()
    d) didUpdateWidget()
  4. What happens when setState() is called in a Stateful widget?
    a) The widget rebuilds completely.
    b) The widget is destroyed.
    c) The widget’s state changes permanently.
    d) No visible change occurs.
  5. Which is true about Stateless widgets?
    a) They can hold a state across rebuilds.
    b) They are ideal for dynamic user interfaces.
    c) They are immutable.
    d) They must use setState() for updates.

Common Widgets: Text, Image, Container, Row, Column

  1. What is the primary purpose of a Container widget?
    a) To display text
    b) To hold and position child widgets
    c) To show images
    d) To create forms
  2. Which widget is used to display a simple piece of text?
    a) TextField
    b) Label
    c) Text
    d) Font
  3. What is the fit property used for in the Image widget?
    a) To position the image within a widget
    b) To adjust the widget’s padding
    c) To define how an image should fill its container
    d) To manage caching for images
  4. Which widget aligns its children in a horizontal direction?
    a) Column
    b) Row
    c) Stack
    d) Flex
  5. What happens if no child is provided to a Container widget?
    a) It throws an error.
    b) It becomes invisible but still occupies space.
    c) It collapses.
    d) It defaults to a Text widget.

Layout Principles: Constraints, Sizes, Padding, and Margins

  1. What does the BoxConstraints class represent in Flutter?
    a) A set of rules for defining widget size
    b) Animation properties for widgets
    c) Color schemes for widgets
    d) Debugging tools
  2. The padding property of a widget:
    a) Adds space outside the widget’s border
    b) Adds space inside the widget’s border
    c) Centers the widget
    d) Changes the widget’s size
  3. What happens when a widget’s size exceeds its parent’s constraints?
    a) It expands without limits.
    b) The widget throws an error.
    c) It clips to fit the constraints.
    d) The layout adjusts dynamically.
  4. Which property controls external spacing around a widget?
    a) margin
    b) padding
    c) constraints
    d) alignment
  5. What is the default alignment for widgets in a Row?
    a) Center
    b) Start
    c) End
    d) Stretch

Customizing Widgets

  1. What method is typically used to customize a widget’s appearance?
    a) setStyle()
    b) applyChanges()
    c) modify()
    d) Decoration property
  2. Which property allows you to set a background color for a Container?
    a) color
    b) backgroundColor
    c) decoration
    d) shade
  3. How do you add rounded corners to a Container?
    a) Using borderRadius in BoxDecoration
    b) Setting the clipShape property
    c) Modifying the cornerRadius attribute
    d) Adding a curve widget
  4. Which widget is used to apply gradients to another widget?
    a) ShaderMask
    b) ColorFilter
    c) Container
    d) GradientBox
  5. How can you add a shadow effect to a widget?
    a) Using the elevation property
    b) Applying a BoxShadow to BoxDecoration
    c) Adding the shadowEffect property
    d) Wrapping the widget in a Shadow widget

Additional Concepts

  1. What is the primary difference between Padding and Margin?
    a) Padding adjusts external space; margin adjusts internal space.
    b) Padding adjusts internal space; margin adjusts external space.
    c) Both do the same function.
    d) Padding is mandatory, margin is optional.
  2. Which property in a Text widget adjusts text alignment?
    a) align
    b) textAlign
    c) justify
    d) direction
  3. To make a widget respond to a tap event, which widget should be used?
    a) GestureDetector
    b) Container
    c) Stack
    d) Row
  4. Which layout widget is ideal for overlaying widgets?
    a) Row
    b) Stack
    c) Flex
    d) Grid
  5. What does the Expanded widget do in a Row or Column?
    a) Forces the widget to center-align
    b) Adds scrollability
    c) Divides available space among widgets
    d) Makes the widget invisible

Answer Table

QnoAnswer
1b) It does not maintain state.
2b) StatefulWidget
3c) initState()
4a) The widget rebuilds completely.
5c) They are immutable.
6b) To hold and position child widgets
7c) Text
8c) To define how an image should fill its container
9b) Row
10b) It becomes invisible but still occupies space.
11a) A set of rules for defining widget size
12b) Adds space inside the widget’s border
13c) It clips to fit the constraints.
14a) margin
15b) Start
16d) Decoration property
17a) color
18a) Using borderRadius in BoxDecoration
19a) ShaderMask
20b) Applying a BoxShadow to BoxDecoration
21b) Padding adjusts internal space; margin adjusts external space.
22b) textAlign
23a) GestureDetector
24b) Stack
25c) Divides available space among widgets

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