Expert · Flutter careers and interviews · topic 49 of 50 · 35 min
Interview questions: Flutter
Explanation
Q1. Widget, Element and RenderObject?
Model answer: "Widgets are immutable descriptions of UI, cheap to create. Elements are the long-lived instances in the element tree that hold a widget's place and, for stateful widgets, its State. RenderObjects do layout and painting. When I rebuild, Flutter compares new widgets with the elements and updates only what changed, which is why rebuilding is cheap."
Q2. StatelessWidget versus StatefulWidget, and the lifecycle?
Model answer: "A StatelessWidget depends only on its constructor arguments. A StatefulWidget has a State object that survives rebuilds: initState runs once for setup, build runs on every rebuild, didUpdateWidget when the parent passes new arguments, and dispose for cleanup. I call setState to rebuild after changing state and check mounted after awaits."
Q3. What is BuildContext?
Model answer: "It is a handle to a widget's location in the element tree. I use it to look up inherited data such as Theme.of(context), MediaQuery and providers, and for navigation. A context from below a provider can find it; one from above cannot, which explains ProviderNotFound errors."
Q4. When do you need keys?
Model answer: "Keys preserve identity when widgets of the same type move, are inserted or removed in a list, so state stays with the right item. I use ValueKey with an id for list items and Dismissible; GlobalKey only when I must reach a widget's state, like a FormState."
Q5. Hot reload versus hot restart?
Model answer: "Hot reload injects changed code and re-runs build methods while keeping state. Hot restart restarts the Dart code and resets state. Changes to main, initState of existing widgets, global initialisers, native code or packages need a restart or full rebuild."
Q6. Explain Flutter's layout model.
Model answer: "Constraints go down, sizes go up, the parent sets the position. Each widget receives min and max constraints and chooses a size within them. Overflow errors come from children wanting more than they are allowed, fixed with Expanded or Flexible, wrapping, scrolling or responsive layouts; a ListView inside a Column needs Expanded because the Column gives unbounded height."
Q7. How do you choose state management?
Model answer: "setState for ephemeral state. For shared state, Provider for simpler apps, Riverpod for compile-safe, testable providers, and Bloc for large teams wanting strict event-to-state structure. The key is consistency and keeping business logic out of widgets so it can be unit tested."
Q8. How do you make a Flutter app fast?
Model answer: "Measure in profile mode with DevTools first. Then use const widgets, keep build methods light, split widgets to reduce rebuild scope, use ListView.builder, cache and resize images, and move heavy work to isolates. Test on a budget Android phone."
Take-home assignments
- Typical brief: fetch a list from an API, show details, maybe search or favourites, in 2 to 4 days.
- Reviewers look for: clean folders and layering (UI, state, data), loading/error/empty states, responsive layout, sensible state management, some unit and widget tests, and a clear README.
- Test on a small phone and in landscape; handle no internet.
- Keep it simple and finished rather than ambitious and broken; list improvements you would make with more time.
Common interview mistakes
- Saying "setState rebuilds the whole app".
- Not knowing why a ListView in a Column crashes.
- Over-engineering a take-home with five layers and no tests.
- Not asking clarifying questions about requirements.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Interview questions: Flutter · 1/6
Widgets describe UI. Elements hold their place and state. Render objects lay out and paint.
Prefer a video by a teacher? Find free videos on “flutter interview questions widget element render object keys buildcontext take home” on YouTube ↗
In real life: A live debugging question
An interviewer shows a Column containing a header Text and a ListView, which crashes with "Vertical viewport was given unbounded height", and asks for a fix. A strong candidate explains the constraint rule (the Column gives unbounded height to its children, and a ListView wants infinite height), proposes wrapping the ListView in Expanded, and mentions why shrinkWrap is a weaker option for long lists.
Column(
children: [
const Text('Orders'),
Expanded(child: ListView.builder(itemCount: 50, itemBuilder: (_, i) => Text('Order $i'))),
],
)Practice (0/3 done)
Why is rebuilding widgets cheap in Flutter?
A ListView inside a Column crashes with unbounded height. The best fix for a long list is…
Do a mock take-home in a weekend: an app that lists items from a public API, opens a details screen, supports search, handles loading, error and empty states, works in landscape and on a tablet, uses one state management approach, and has at least 3 unit and 2 widget tests. Write a README with decisions and improvements.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Portfolio and next stepsFlutter careers and interviews · same module
- Flutter jobs and freelancing in IndiaFlutter careers and interviews · same module
- Interview questions: Android and ComposeKotlin and Android App Development · Android career path
- Everything is a widgetFlutter setup and your first app
- Interview questions: ownership, borrowing and lifetimesRust Programming · Rust careers and interviews
- Interview questions: KotlinKotlin and Android App Development · Android career path
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Which object holds a StatefulWidget's State between rebuilds?
Answer: The element
Elements are long-lived.
Which needs a hot restart rather than a hot reload?
Answer: Changing the initial value set in initState of an existing widget
initState does not run again on reload.
What causes ProviderNotFoundException?
Answer: Reading a provider from a context that is not below it
Context position matters.
What matters most in a take-home assignment?
Answer: A working, clean, tested app with handled states and a clear README
Quality over quantity.
When should you choose a StatelessWidget?Related
Answer: When everything it shows comes from its constructor arguments
Start stateless by default.
What do reviewers most often check first in a take-home Android app?Related
Answer: Whether it runs, handles states and rotation, and has clean structure
Working basics and clean structure matter most.
Which key triggers hot restart in the flutter run terminal?Related
Which Dart 3 feature makes a switch over UI states exhaustive?Related
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 1 more topic in “Flutter careers and interviews” before its exam: Portfolio and next steps.
- Module 12 exam: Flutter careers and interviews · 10 questions · 20 min, without help. 4 topics of this module still to finish first.
- 50 topics left in the course before the final exam.