Flutter quiz

Widgets, layouts, state and Dart basics for building apps.

67 questionsInstant feedbackFree

Set up your quiz

Difficulty
Number of questions

Tip: press 1–4 to answer and Enter for the next question.

All 67 questions with answers
  1. Who developed Flutter?

    • Facebook
    • Google (correct)
    • Microsoft
    • Apple
  2. Which programming language is used to write Flutter apps?

    • Java
    • Kotlin
    • Dart (correct)
    • Swift
  3. In Flutter, almost everything is a:

    • Widget (correct)
    • Activity
    • Fragment
    • View
  4. Which widget type should you use when the UI must change based on internal mutable state?

    • StatelessWidget
    • InheritedWidget
    • StatefulWidget (correct)
    • Container
  5. Which method triggers a UI rebuild after state changes in a State class?

    • refresh()
    • update()
    • rebuild()
    • setState() (correct)
  6. Which widget arranges its children in a vertical line?

    • Column (correct)
    • Row
    • Stack
    • Wrap
  7. Which file lists a Flutter project's dependencies?

    • package.json
    • pubspec.yaml (correct)
    • build.gradle
    • pom.xml
  8. Which widget overlaps its children on top of each other?

    • Row
    • Column
    • Stack (correct)
    • Wrap
  9. What does Hot Reload do?

    • Restarts the app and clears all state
    • Injects updated code while preserving app state (correct)
    • Builds a release APK
    • Clears the device cache
  10. Which widget builds list items lazily as they scroll into view?

    • Column
    • Row
    • Stack
    • ListView.builder (correct)
  11. What is BuildContext?

    • A handle to a widget's location in the widget tree (correct)
    • A database connection
    • A build configuration file
    • A type of animation
  12. What does a Future represent in Dart?

    • A constant value
    • A loop construct
    • A value that will be available later (correct)
    • A UI widget
  13. What does Navigator.push() do?

    • Removes all routes
    • Adds a new route on top of the navigation stack (correct)
    • Closes the app
    • Reloads the current screen
  14. Which widget provides basic Material Design layout such as appBar and body?

    • Container
    • Center
    • Padding
    • Scaffold (correct)
  15. When is initState() called?

    • On every rebuild
    • When the widget is disposed
    • Once, when the State object is inserted into the tree (correct)
    • Only on hot restart
  16. What is the difference between final and const in Dart?

    • There is no difference
    • const is a compile-time constant, final is assigned once at runtime (correct)
    • final is compile-time, const is runtime
    • const can be reassigned
  17. What is an InheritedWidget used for?

    • Efficiently passing data down the widget tree (correct)
    • Making HTTP requests
    • Creating animations
    • Storing local files
  18. Which three trees does Flutter use internally?

    • Widget, State, View
    • Model, View, Controller
    • Widget, Element, RenderObject (correct)
    • Component, Node, Layer
  19. What is the purpose of Keys in Flutter?

    • To encrypt widget data
    • To preserve widget state and identity when widgets move in the tree (correct)
    • To store API keys
    • To speed up compilation
  20. What are Isolates in Dart?

    • Shared-memory threads
    • Private class members
    • Independent workers with their own memory that communicate by messages (correct)
    • Database transactions
  21. Which command creates a new Flutter project?

    • flutter init my_app
    • flutter create my_app (correct)
    • dart new my_app
    • flutter new my_app
  22. Which command runs a Flutter app on a connected device?

    • flutter run (correct)
    • flutter start
    • dart start
    • flutter go
  23. Which function is the entry point of a Flutter app?

    • main() (correct)
    • init()
    • start()
    • runApp() only
  24. Which function attaches the root widget to the screen?

    • startApp()
    • attach()
    • runApp() (correct)
    • setRoot()
  25. Which widget displays a line of text?

    • Label
    • TextView
    • Text (correct)
    • String
  26. Which widget arranges children horizontally?

    • Column
    • Row (correct)
    • Stack
    • ListView
  27. Which widget adds empty space around its child?

    • Padding (correct)
    • Gap only
    • Space
    • Margin
  28. Which widget is a box that can have colour, size, padding and decoration?

    • Container (correct)
    • Panel
    • Frame
    • Box
  29. Which widget shows an image from the internet?

    • WebImage
    • NetworkPicture
    • Image.web
    • Image.network (correct)
  30. Which widget is a clickable Material button with a raised look?

    • ClickButton
    • RaisedText
    • ElevatedButton (correct)
    • PressButton
  31. Which keyword declares a variable that cannot be reassigned in Dart?

    • var
    • dynamic
    • let
    • final (correct)
  32. Which widget takes up the remaining space inside a Row or Column?

    • Flexiblebox
    • Spacer only with size
    • Container
    • Expanded (correct)
  33. Which widget is used for the top bar in a Scaffold?

    • AppBar (correct)
    • TopBar
    • Header
    • NavBar
  34. Which widget makes its child scroll if it is too tall?

    • SingleChildScrollView (correct)
    • ScrollBox
    • OverflowView
    • Scrollable only
  35. Which Dart type stores text?

    • char
    • String (correct)
    • str
    • Text
  36. What is the difference between StatelessWidget and StatefulWidget?

    • They are identical
    • A StatefulWidget has mutable State that can trigger rebuilds (correct)
    • StatelessWidget can call setState
    • StatefulWidget cannot have children
  37. Which method must every widget class implement to describe its UI?

    • build() (correct)
    • render()
    • paint()
    • draw()
  38. What does mainAxisAlignment control in a Column?

    • Horizontal alignment
    • Padding
    • Vertical alignment of children (correct)
    • Text style
  39. What does crossAxisAlignment control in a Row?

    • Horizontal alignment
    • Scrolling
    • The number of children
    • Vertical alignment of children (correct)
  40. Which widget reads user text input?

    • InputBox
    • TextInput
    • TextField (correct)
    • EditText
  41. Which widget detects taps on any child widget?

    • TouchListener
    • TapView
    • GestureDetector (correct)
    • ClickArea
  42. What does the const keyword before a widget constructor help with?

    • Prevents user input
    • Makes the widget invisible
    • Reuses the widget instance and avoids unnecessary rebuilds (correct)
    • Makes the widget stateful
  43. Which Navigator method goes back to the previous screen?

    • Navigator.exit(context)
    • Navigator.back(context)
    • Navigator.close(context)
    • Navigator.pop(context) (correct)
  44. Which widget builds UI from the result of a Future?

    • LoaderWidget
    • FutureBuilder (correct)
    • PromiseBuilder
    • AsyncWidget
  45. Which widget rebuilds when a Stream emits new values?

    • EventBuilder
    • ListenerView
    • StreamWidget
    • StreamBuilder (correct)
  46. What do the async and await keywords do in Dart?

    • Let you write asynchronous code that waits for Futures (correct)
    • Run code at compile time
    • Create isolates
    • Make code synchronous
  47. What does the ?? operator do in Dart?

    • Checks equality
    • Casts a value
    • Creates a list
    • Returns the right side if the left side is null (correct)
  48. Which file is the usual place to declare app assets like images?

    • AndroidManifest.xml only
    • pubspec.yaml (correct)
    • main.dart
    • assets.json
  49. Which command downloads the packages listed in pubspec.yaml?

    • flutter install
    • flutter pub get (correct)
    • dart download
    • flutter packages build
  50. What is the Provider package mainly used for?

    • Networking only
    • Database storage
    • Animations
    • State management and dependency injection (correct)
  51. What does MediaQuery.of(context).size give you?

    • The screen size (correct)
    • The font size
    • The widget's size
    • The image size
  52. Inside a Row, which widget lets its child use up to its share of free space without being forced to fill it?

    • Flexible (correct)
    • Spacer
    • SizedBox
    • Expanded
  53. What does the Wrap widget do?

    • Hides overflow
    • Wraps text in quotes
    • Moves children to a new line when they run out of space (correct)
    • Adds a border
  54. Which method is called when a State object is removed permanently?

    • deactivate() only
    • dispose() (correct)
    • close()
    • destroy()
  55. Which Dart collection holds key-value pairs?

    • Map (correct)
    • Set
    • Queue
    • List
  56. What is the difference between hot reload and hot restart?

    • Hot restart resets app state; hot reload keeps it (correct)
    • They are identical
    • Hot reload resets state
    • Hot restart only reloads CSS
  57. What does a GlobalKey allow you to do?

    • Speed up builds
    • Make a widget global for all apps
    • Encrypt data
    • Access a widget's state or context from elsewhere (correct)
  58. What does didChangeDependencies() respond to?

    • Changes in inherited widgets the State depends on (correct)
    • Disposal of the widget
    • Every frame
    • Network changes
  59. What is the purpose of the late keyword in Dart?

    • Running code asynchronously
    • Declaring a non-nullable variable that will be initialized later (correct)
    • Declaring a constant
    • Delaying code execution
  60. What does Dart's sound null safety guarantee?

    • No variable can be null
    • All variables are nullable
    • Null checks are done at runtime only
    • Non-nullable variables can never hold null at runtime (correct)
  61. What does a RenderObject do in Flutter?

    • Fetches data
    • Handles navigation
    • Handles layout and painting (correct)
    • Stores app state
  62. Which widget efficiently builds a scrollable grid lazily?

    • Wrap
    • GridView.builder (correct)
    • GridView.count only
    • Table
  63. Which approach should you use for heavy CPU work so the UI stays smooth?

    • Use setState more often
    • Run it in a separate isolate, for example with compute() (correct)
    • Use a StatelessWidget
    • Increase the frame rate
  64. Which Flutter tool helps you inspect the widget tree and performance?

    • Chrome Lighthouse
    • Xcode Instruments only
    • Flutter DevTools (correct)
    • Android Monitor only
  65. What is the purpose of a Key when reordering list items with state?

    • It speeds up scrolling only
    • It lets Flutter match each item's State to the correct widget (correct)
    • It encrypts list items
    • It sorts the list
  66. What does the mounted property of a State tell you?

    • Whether the app is running
    • Whether the widget is visible on screen
    • Whether the State is still in the widget tree (correct)
    • Whether data has loaded
  67. What does AnimationController need to run animations in sync with the screen?

    • A Future
    • A GlobalKey
    • A Stream
    • A vsync (TickerProvider) (correct)