Dart

  • By Language
  • 40 questions

What this round is for

Dart interviews are usually Flutter interviews, and the questions that separate candidates are about the frame budget: what causes a rebuild, what blocks the UI isolate, and why const is more than a style choice.

The language half concentrates on sound null safety and on the difference between asynchronous waiting and genuine parallelism, which is the distinction most candidates get wrong.

The questions

Answer each one out loud before you open it. An answer you have read is not an answer you can give under pressure, which is the only kind that counts.

Q1 Why does Dart have two compilers?

Show the answer Hide the answer

A JIT during development for hot reload, and AOT for release so start-up is fast and performance predictable.

Hot reload updates a running app in under a second while keeping state, which transforms the UI development loop.

What it is really testing. Whether you know why both exist rather than treating it as an oddity.

Q2 What is hot reload and what are its limits?

Show the answer Hide the answer

It injects changed code into the running app and rebuilds the widget tree, keeping current state.

It cannot handle changes to global state initialisers, enums or class hierarchies - those need a hot restart, which loses state.

What it is really testing. Whether you know what hot reload cannot do. Everyone knows what it can.

Q3 What is sound null safety?

Show the answer Hide the answer

Types are non-nullable by default, and the compiler can rely on that guarantee.

Soundness means no path can put null in a non-nullable variable, so the compiler can omit null checks from the output - a real performance gain.

What it is really testing. Whether you can explain what sound adds over a warning-based system.

Q4 What do ?, !, ?? and ??= do?

Show the answer Hide the answer

? marks a nullable type or a safe call, ! asserts non-null, ?? supplies a fallback, ??= assigns only if null.

The ! operator throws at run time if it is wrong, so reaching for it often means the types are wrong upstream.

What it is really testing. Whether you treat ! as a last resort rather than a convenience.

Q5 What is the difference between final and const?

Show the answer Hide the answer

final means assigned once at run time; const means the value is known at compile time.

A const value is canonicalised, so identical const objects are the same instance - which is why const widgets can be skipped during rebuilds.

What it is really testing. Whether you know const is canonicalised, which is why it matters in Flutter.

Q6 Why does const matter so much in Flutter?

Show the answer Hide the answer

A const widget can be reused rather than rebuilt, so the framework skips work.

It is a measurable performance practice rather than a style preference, which is unusual for a keyword.

What it is really testing. Whether you connect a keyword to measurable frame performance.

Q7 What is an isolate?

Show the answer Hide the answer

A unit of concurrency with its own memory and its own garbage collector.

Isolates share nothing and communicate by message, so data races are not expressible rather than merely discouraged.

What it is really testing. Whether you know they share no memory, which is the whole point.

Q8 Why do isolates help with animation?

Show the answer Hide the answer

Each collects its own heap, so a background isolate's garbage collection does not pause the UI isolate.

In a shared-heap language a collection stops every thread, including the one drawing the screen.

What it is really testing. Whether you connect isolates to garbage collection pauses rather than just parallelism.

Q9 What is the difference between async work and an isolate?

Show the answer Hide the answer

await frees the thread while waiting; an isolate moves actual computation elsewhere.

Awaiting a function that spends two seconds computing still freezes the interface, because the computation ran on the same thread.

What it is really testing. Whether you know await does not move work off the thread.

Q10 What is a Future?

Show the answer Hide the answer

An object representing a value that will exist later, which can complete with a value or an error.

async functions always return one, and await suspends the function without blocking the event loop.

What it is really testing. Whether you know it can complete with an error as well as a value.

Q11 What is a Stream and how does it differ from a Future?

Show the answer Hide the answer

A Future is one value; a Stream is zero or more arriving over time.

User input, websocket messages and state changes are naturally streams, consumed with await for or a listener.

What it is really testing. Whether you can name data that is naturally a stream.

Q12 What is the difference between a single-subscription and a broadcast stream?

Show the answer Hide the answer

A single-subscription stream allows one listener; a broadcast stream allows many.

Listening twice to a single-subscription stream throws, which is a common error when a widget subscribes on every rebuild.

What it is really testing. Whether you know listening twice to the wrong kind throws.

Q13 How do you handle errors in asynchronous Dart?

Show the answer Hide the answer

try/catch around await, or catchError on a Future.

A Future you neither await nor catch produces an unhandled error that may surface far from its cause.

What it is really testing. Whether you know an unawaited Future can swallow an error.

Q14 What is the difference between Error and Exception?

Show the answer Hide the answer

Error signals a programming mistake you should fix; Exception signals an anticipated condition you should handle.

Catching an Error usually means hiding a programming bug rather than handling a situation you anticipated.

What it is really testing. Whether you know you are not meant to catch an Error.

Q15 What are mixins for?

Show the answer Hide the answer

Sharing behaviour across classes without inheritance and without the single-parent limit.

A class can mix in several, which is how shared capabilities are distributed in Flutter code.

What it is really testing. Whether you know why they exist given single inheritance.

Q16 What is the difference between extends, implements and with?

Show the answer Hide the answer

extends inherits implementation, implements requires you to provide everything, with mixes in behaviour.

implements on a concrete class takes only its interface, so every member must be reimplemented.

What it is really testing. Whether you know implements discards the implementation entirely.

Q17 What is an extension method?

Show the answer Hide the answer

A way to add methods to a type you do not own, resolved statically and scoped to importing files.

Unlike monkey patching it cannot surprise code that did not import it, which is the whole difference.

What it is really testing. Whether you know it is scoped, unlike monkey patching in other languages.

Q18 What is a factory constructor?

Show the answer Hide the answer

A constructor that may return an existing instance or a subclass rather than always making a new object.

It is how caching, singletons and parsing constructors are written, and the caller cannot tell the difference from an ordinary constructor.

What it is really testing. Whether you can name a use beyond singletons.

Q19 What are named and required parameters?

Show the answer Hide the answer

Named parameters are passed by name; required marks the ones that must be supplied.

They make calls with many optional parameters readable, which matters when a widget takes fifteen of them.

What it is really testing. Whether you connect them to readability at the call site.

Q20 What do spread, collection-if and collection-for do?

Show the answer Hide the answer

They let you insert another collection, a conditional element, or generated elements inside a literal.

Without them, a conditional child in a widget tree would force the surrounding structure into imperative code.

What it is really testing. Whether you know why they matter specifically for widget trees.

Q21 What is the difference between List, Set and Map?

Show the answer Hide the answer

List is ordered with duplicates, Set is unique with fast membership, Map is key to value.

Choosing a Set for membership checks is the usual fix for a loop that scans a list repeatedly.

What it is really testing. Whether you pick a Set when membership is the operation.

Q22 What is the difference between growable and fixed-length lists?

Show the answer Hide the answer

A list literal is growable; List.filled without growable set is fixed.

Adding to a fixed-length list throws at run time, which surprises people who only ever used literals.

What it is really testing. Whether you know fixed-length lists exist and throw on add.

Q23 What is dynamic and why avoid it?

Show the answer Hide the answer

It disables static checking for that value, deferring every error to run time.

Object? is usually the honest alternative - it also means unknown, but requires a check before use.

What it is really testing. Whether you reach for Object? instead, which is the honest alternative.

Q24 What does late do?

Show the answer Hide the answer

It defers initialisation of a non-nullable variable until first use.

If it is read before assignment it throws, so it trades a compile-time guarantee for a run-time one.

What it is really testing. Whether you know it trades a compile-time guarantee for a run-time one.

Q25 How do you make a class comparable or usable as a map key?

Show the answer Hide the answer

Override == and hashCode consistently.

If equal objects return different hash codes, the object becomes unfindable in a map with no error raised.

What it is really testing. Whether you know the consequence of breaking the contract - a lost map entry.

Q26 What is the difference between int on native and on the web?

Show the answer Hide the answer

Native int is 64-bit; compiled to JavaScript it uses a 64-bit float with 53 bits of integer precision.

Large integers can lose precision on the web only, which is a narrow but real cross-platform trap.

What it is really testing. Whether you know the web differs. It is a genuine cross-platform trap.

Q27 What is a generic in Dart and why use one?

Show the answer Hide the answer

A type parameter preserving the relationship between input and output types.

Without it a reusable container returns dynamic and all type information is lost at the call site.

What it is really testing. Whether you know what is lost without one.

Q28 What is the difference between StatelessWidget and StatefulWidget?

Show the answer Hide the answer

Stateless depends only on its inputs; stateful holds mutable state across rebuilds.

Using stateful where stateless would do adds lifecycle complexity for no benefit.

What it is really testing. Whether you default to stateless. Overusing stateful is a common habit.

Q29 What does the build method's contract require?

Show the answer Hide the answer

That it is pure and fast - it can be called many times per second.

Doing network calls or heavy computation inside build is the most common cause of a janky Flutter app.

What it is really testing. Whether you know build can run many times a second.

Q30 What is a Key for in Flutter?

Show the answer Hide the answer

It helps the framework match widgets to state when the list of children changes.

Without keys, reordering a list can attach the wrong state to the wrong item, producing visibly wrong results.

What it is really testing. Whether you can explain what goes wrong without keys.

Q31 What is BuildContext?

Show the answer Hide the answer

A handle to a widget's position in the tree, used to look up inherited widgets.

Using a context after its widget is disposed is a frequent source of errors, especially after an await.

What it is really testing. Whether you know the risk of using a context after an await.

Q32 What is an InheritedWidget?

Show the answer Hide the answer

A widget that propagates data down the tree and rebuilds dependents when it changes.

It is the mechanism underneath Theme, MediaQuery and most state management libraries.

What it is really testing. Whether you know it underlies Theme and MediaQuery.

Q33 How do you choose a state management approach?

Show the answer Hide the answer

By how far state must travel and how often it changes.

Local state belongs in a StatefulWidget; shared state needs something that propagates. Reaching for a large solution for local state adds indirection without benefit.

What it is really testing. Whether you choose by scope rather than by fashion.

Q34 What is pubspec.yaml for?

Show the answer Hide the answer

Declaring dependencies, assets, fonts and the SDK constraint.

The lock file records resolved versions so builds are reproducible across machines.

What it is really testing. Whether you can explain why the lock file matters.

Q35 What does the Dart formatter configure?

Show the answer Hide the answer

Nothing - it has no options.

That sounds authoritarian and ends style arguments permanently, so every Dart codebase looks the same.

What it is really testing. Whether you see unconfigurable formatting as a feature.

Q36 What is a widget test?

Show the answer Hide the answer

A test running a piece of interface headlessly, with taps and assertions, in milliseconds.

It sits between unit tests that cannot see the UI and integration tests too slow to run often.

What it is really testing. Whether you know this middle tier exists. Many candidates do not.

Q37 How do you avoid rebuilding too much in Flutter?

Show the answer Hide the answer

Keep rebuilds narrow with const widgets, small widget classes and targeted state scopes.

Rebuilding a large subtree for a small change is work the framework cannot optimise away for you.

What it is really testing. Whether you think about rebuild scope rather than only about correctness.

Q38 What is the difference between SizedBox and Container?

Show the answer Hide the answer

SizedBox only sizes; Container composes padding, decoration, constraints and more.

Using Container for a simple gap creates more render objects than needed, which adds up in a long list.

What it is really testing. Whether you consider render object count in long lists.

Q39 How does Dart handle string interpolation and raw strings?

Show the answer Hide the answer

Dollar syntax interpolates expressions; a leading r makes a raw string.

Raw strings matter for regular expressions and paths where backslashes would otherwise be escapes.

What it is really testing. Whether you know where raw strings are genuinely needed.

Q40 Where is Dart a good choice outside Flutter?

Show the answer Hide the answer

It compiles to fast native binaries and makes a capable server or CLI language.

The honest caveat is that the server ecosystem is small, so you will write more yourself than in an established alternative.

What it is really testing. Whether you can be honest about the ecosystem rather than overselling it.

Two things worth doing in the room

  • When asked about performance, say whether the problem is waiting or working. That one distinction decides between async and an isolate and shows you understand the model.
  • If a question is about Flutter, mention what the framework can skip - const widgets, narrow rebuild scopes. Interviewers are listening for awareness that build runs constantly.