Flutter interview questions

25 questions from the Flutter course, each with the correct answer and an explanation. Try to answer before you open the answer.

Flutter Foundations

1. How does Flutter draw its user interface?

  1. It runs inside a WebView on every platform
  2. It converts widgets into native Android and iOS views
  3. Its own engine renders every pixel, rather than using native platform widgets
  4. It generates HTML for all targets
Show answer

Answer: Its own engine renders every pixel, rather than using native platform widgets

Flutter owns the rendering pipeline, which gives consistent visuals across platforms.

Lesson: What Flutter Is

2. What is the key difference between hot reload and hot restart?

  1. Hot reload keeps app state; hot restart resets it
  2. Hot reload recompiles native Android and iOS code
  3. Hot restart only works in release mode
  4. There is no difference
Show answer

Answer: Hot reload keeps app state; hot restart resets it

Hot reload patches code into the running VM and rebuilds; hot restart starts the Dart app again.

Lesson: Setting Up and Hot Reload

3. What is the difference between final and const in Dart?

  1. final only works on classes
  2. They are identical
  3. const variables can be reassigned
  4. final is set once at runtime; const must be known at compile time
Show answer

Answer: final is set once at runtime; const must be known at compile time

const values are canonicalised compile-time constants, which Flutter uses to skip rebuild work.

Lesson: Dart Essentials for Flutter

Thinking in Widgets

4. Which tree performs layout and painting in Flutter?

  1. The widget tree
  2. The render tree of RenderObjects
  3. The pubspec tree
  4. The navigation stack
Show answer

Answer: The render tree of RenderObjects

Widgets describe, elements manage, render objects lay out and paint.

Lesson: The Widget Tree

5. Where should you release a TextEditingController or StreamSubscription?

  1. In build()
  2. In dispose()
  3. In the widget constructor
  4. Nowhere; Dart frees them automatically
Show answer

Answer: In dispose()

dispose is the State's cleanup hook; forgetting it leaks listeners and resources.

Lesson: StatelessWidget and StatefulWidget

6. Why add a ValueKey to items in a list that can be reordered?

  1. Keys are required on every widget
  2. To make the list scroll faster
  3. To translate the items
  4. So Flutter matches each widget and its state to the right item by identity
Show answer

Answer: So Flutter matches each widget and its state to the right item by identity

Without keys, matching is by type and position, which breaks when order changes.

Lesson: const Constructors and Keys

Layout and Scrolling

7. A Text inside a Row overflows. What is the usual fix?

  1. Wrap it in Expanded or Flexible so it is given a bounded width
  2. Wrap the Row in a Center
  3. Add a ValueKey
  4. Call setState
Show answer

Answer: Wrap it in Expanded or Flexible so it is given a bounded width

Row gives children unbounded main-axis space unless they are flexible.

Lesson: Row, Column and Constraints

8. Which widget lets you place a child at a specific offset from the edges of a Stack?

  1. Flexible
  2. Expanded
  3. Positioned
  4. Padding
Show answer

Answer: Positioned

Positioned works only as a direct child of a Stack.

Lesson: Container, Padding, SizedBox and Stack

9. Why prefer ListView.builder for a list of 10,000 items?

  1. It caches network images
  2. It sorts items automatically
  3. It builds items lazily as they scroll into view
  4. It is the only list that supports scrolling
Show answer

Answer: It builds items lazily as they scroll into view

Lazy building keeps memory and build time proportional to what is visible.

Lesson: Responsive Layouts and Lists

User Input and Theming

10. What should a TextFormField validator return when the value is valid?

  1. null
  2. An empty string
  3. true
  4. The value itself
Show answer

Answer: null

Any non-null string is treated as an error message.

Lesson: Forms and Validation

11. How do you disable a Material button?

  1. Give it a GlobalKey
  2. Set enabled: false on every button type
  3. Wrap it in a Stack
  4. Pass null as its onPressed callback
Show answer

Answer: Pass null as its onPressed callback

A null callback renders the disabled style and ignores taps.

Lesson: Buttons and Gestures

12. What does ColorScheme.fromSeed do?

  1. Downloads a theme from the internet
  2. Generates a complete, harmonious colour scheme from one seed colour
  3. Picks random colours each launch
  4. Only sets the AppBar colour
Show answer

Answer: Generates a complete, harmonious colour scheme from one seed colour

It derives tonal palettes for every Material colour role.

Lesson: Material 3 Theming and Dark Mode

Navigation and Routing

13. How does a pushed screen return a value to the screen that opened it?

  1. By writing to a global variable only
  2. By passing it to Navigator.pop, which completes the Future returned by push
  3. By calling setState on the parent
  4. Screens cannot return values
Show answer

Answer: By passing it to Navigator.pop, which completes the Future returned by push

push returns a Future that completes with the pop result.

Lesson: Navigator Push and Pop

14. What is a main advantage of declarative routing with go_router?

  1. It replaces state management
  2. It removes the need for widgets
  3. It makes apps compile faster
  4. Screens are addressable by URL, which supports the web and deep links
Show answer

Answer: Screens are addressable by URL, which supports the web and deep links

Paths map directly to screens, so external links can open any page.

Lesson: Declarative Routing With go_router

15. Why prefer passing an ID in the URL over passing a whole object with extra?

  1. The screen can be rebuilt from the URL alone, so refreshes and deep links work
  2. Objects cannot be passed in Dart
  3. URLs are encrypted
  4. extra is slower to type
Show answer

Answer: The screen can be rebuilt from the URL alone, so refreshes and deep links work

Data that is not in the URL is lost when the app is opened from a link.

Lesson: Passing Data and Deep Links

State Management

16. What happens when an InheritedWidget changes and updateShouldNotify returns true?

  1. Nothing until hot reload
  2. The whole app restarts
  3. Widgets that depend on it via dependOnInheritedWidgetOfExactType rebuild
  4. Only the root widget rebuilds
Show answer

Answer: Widgets that depend on it via dependOnInheritedWidgetOfExactType rebuild

Dependents are tracked and rebuilt automatically.

Lesson: Lifting State and InheritedWidget

17. Which call should you use inside a button's onPressed to call a method on a provided model?

  1. setState()
  2. context.watch<T>()
  3. context.read<T>()
  4. Navigator.of(context)
Show answer

Answer: context.read<T>()

read fetches the object without subscribing the widget to changes.

Lesson: Provider and ChangeNotifier

18. In Bloc, how does a Cubit publish a new state?

  1. By calling emit(newState)
  2. By calling notifyListeners()
  3. By calling setState()
  4. By returning a widget
Show answer

Answer: By calling emit(newState)

emit pushes the new state to BlocBuilder and other listeners.

Lesson: Riverpod, Bloc and How to Choose

Data and the Platform

19. Why should the Future for a FutureBuilder not be created inside build()?

  1. It would run on a different isolate
  2. FutureBuilder only accepts Streams
  3. Futures cannot be created in widgets
  4. build can run many times, so the request would be repeated on every rebuild
Show answer

Answer: build can run many times, so the request would be repeated on every rebuild

Create it once and pass the same Future on each build.

Lesson: HTTP, JSON and FutureBuilder

20. Where should you store an authentication token on the device?

  1. In shared_preferences as plain text
  2. In secure storage such as flutter_secure_storage
  3. In a Dart global variable only
  4. In the app's assets folder
Show answer

Answer: In secure storage such as flutter_secure_storage

Secure storage uses the platform keychain or keystore.

Lesson: Local Storage

21. What Dart class sends method calls to native Android or iOS code?

  1. FutureBuilder
  2. MethodChannel
  3. InheritedWidget
  4. GoRouter
Show answer

Answer: MethodChannel

Native code registers a handler on the same channel name.

Lesson: Platform Channels, Plugins and Permissions

Testing, Performance and Release

22. In a widget test, what must you call after tapping a button that calls setState?

  1. Nothing; the UI updates instantly
  2. flutter run
  3. tester.dispose()
  4. tester.pump() to build the next frame
Show answer

Answer: tester.pump() to build the next frame

The test environment only rebuilds when you pump frames.

Lesson: Unit, Widget and Integration Tests

23. Which build mode should you use to measure performance?

  1. Profile mode on a real device
  2. Debug mode on an emulator
  3. Hot reload
  4. Release mode with DevTools disabled always
Show answer

Answer: Profile mode on a real device

Debug mode adds assertions and JIT overhead; profile mode is close to release but still supports DevTools.

Lesson: Performance and DevTools

24. Which command produces the artifact normally uploaded to Google Play?

  1. flutter run --release
  2. flutter build ipa
  3. flutter build appbundle
  4. flutter pub publish
Show answer

Answer: flutter build appbundle

Google Play expects an Android App Bundle (.aab).

Lesson: Building and Releasing

25. Which practice belongs on a Flutter release checklist?

  1. Hard-code API secrets in Dart files
  2. Ship debug builds to the stores
  3. Run analysis and tests in CI and build signed, versioned releases
  4. Skip testing large text sizes
Show answer

Answer: Run analysis and tests in CI and build signed, versioned releases

Automated checks and proper signing make releases repeatable and safe.

Lesson: A Production Readiness Checklist

← Back to the course