More Programming

Dart interview questions

Interviewers probe a candidate's grasp of Dart's core language features, null safety, async programming, and object-oriented design, as well as their ability to write clean, idiomatic code.

18 questions (8 easy · 7 medium · 3 hard), each with what a strong answer covers and where people lose the point. Free to read, no account.

On this page (18 questions)
  1. 1.Explain how Dart's null safety works. What is the difference between `String` and `String?`? How does type promotion help?
  2. 2.What is the difference between a `Future` and a `Stream` in Dart? Provide examples of when you would use each.
  3. 3.How do `async` and `await` work in Dart? What happens when you `await` a Future?
  4. 4.What is a mixin in Dart and how does it differ from a class? When would you use a mixin instead of inheritance?
  5. 5.Explain the difference between `const` and `final` in Dart. When would you use each?
  6. 6.Compare and contrast `List`, `Set`, and `Map` in Dart. What are the performance implications of each?
  7. 7.How do generics work in Dart? What does it mean that generics are reified?
  8. 8.What is a factory constructor in Dart? How does it differ from a generative constructor? Provide an example.
  9. 9.What are extension methods in Dart? How do they work and what are their limitations?
  10. 10.How does operator overloading work in Dart? What operators can be overridden? What are the pitfalls?
  11. 11.What is pattern matching in Dart? How can it be used with switch expressions and destructuring?
  12. 12.What are records in Dart? How do they differ from classes? When would you use a record?
  13. 13.How does error handling work in Dart? What is the difference between `Exception` and `Error`?
  14. 14.What are isolates in Dart? How do they differ from threads? How do you communicate between isolates?
  15. 15.Explain Dart's type system. What is sound typing? How does it relate to `dynamic`, `Object`, and `var`?
  16. 16.What are collection-if and collection-for in Dart? How do they improve code readability?
  17. 17.What is cascade notation (`..`) in Dart? How does it work and when is it useful?
  18. 18.What are typedefs in Dart? How do they help in writing cleaner code?

1.Explain how Dart's null safety works. What is the difference between `String` and `String?`? How does type promotion help?

Warm-up

What a strong answer covers

  • Define null safety as a compile-time feature that prevents null reference errors.
  • Explain that types are non-nullable by default; `String?` allows null.
  • Describe type promotion: after a null check, the variable is promoted to non-nullable within the scope.
  • Mention that promotion works for local variables but not for instance variables due to potential modification.
  • Give an example of using `?.`, `??`, and `!` operators to handle nulls.

Where people lose the point

  • Claiming that null safety is only a runtime feature.
  • Overusing the `!` operator without proper checks, leading to runtime null errors.
  • Assuming type promotion works on instance variables without using local copies.
Link to this question

2.What is the difference between a `Future` and a `Stream` in Dart? Provide examples of when you would use each.

Warm-up

What a strong answer covers

  • Define `Future` as a single asynchronous result, and `Stream` as a sequence of asynchronous events.
  • Explain that `Future` is used for one-shot operations like HTTP requests or file reads.
  • Explain that `Stream` is used for continuous data like user input, WebSocket messages, or timers.
  • Mention that you can `await` a Future, but for Streams you use `listen` or `await for`.
  • Give a concrete example: fetching a user profile (Future) vs. listening to a chat feed (Stream).

Where people lose the point

  • Confusing the two and using a Future where a Stream is needed.
  • Thinking that a Stream can only emit one value.
  • Not handling errors in streams, leading to unhandled exceptions.
Link to this question

3.How do `async` and `await` work in Dart? What happens when you `await` a Future?

Warm-up

What a strong answer covers

  • Explain that `async` marks a function as asynchronous, making it return a Future.
  • Describe that `await` suspends the current function until the Future completes, without blocking the thread.
  • Mention that `await` can only be used inside an `async` function.
  • Explain that errors in awaited Futures can be caught with try-catch.
  • Discuss that multiple `await`s run sequentially unless you use `Future.wait` for parallelism.

Where people lose the point

  • Thinking that `await` blocks the entire program.
  • Using `await` in a non-async function.
  • Forgetting to handle errors, causing unhandled exceptions.
Link to this question

4.What is a mixin in Dart and how does it differ from a class? When would you use a mixin instead of inheritance?

Core

What a strong answer covers

  • Define a mixin as a class that provides methods and properties for reuse without being instantiated.
  • Explain that mixins are used with the `with` keyword and can be applied to multiple classes.
  • Contrast with inheritance: a class can only extend one superclass, but can use multiple mixins.
  • Mention that mixins cannot have constructors and are subject to linearization order.
  • Give an example: a `Logger` mixin that adds logging methods to various classes.

Where people lose the point

  • Thinking mixins are the same as abstract classes.
  • Trying to instantiate a mixin directly.
  • Ignoring the order of mixins when they override the same method.
Link to this question

5.Explain the difference between `const` and `final` in Dart. When would you use each?

Warm-up

What a strong answer covers

  • Define `final` as a variable that can only be set once, but the value is determined at runtime.
  • Define `const` as a compile-time constant, meaning the value must be known at compile time.
  • Explain that `const` can be used for variables and also for creating constant collections and objects.
  • Mention that `const` implies `final`, but not vice versa.
  • Give examples: `final now = DateTime.now();` vs `const pi = 3.14;`.

Where people lose the point

  • Using `const` for values that are not known at compile time.
  • Thinking that `final` variables are immutable in the sense of deep immutability.
  • Confusing `const` with `static final`.
Link to this question

6.Compare and contrast `List`, `Set`, and `Map` in Dart. What are the performance implications of each?

Core

What a strong answer covers

  • Describe `List` as an ordered collection with index-based access, allowing duplicates.
  • Describe `Set` as an unordered collection with unique elements, optimized for membership tests.
  • Describe `Map` as a collection of key-value pairs, with fast lookups by key.
  • Discuss time complexity: List access O(1), Set contains O(1) on average, Map lookup O(1) on average.
  • Mention that Sets and Maps use hash codes, so elements must have proper `==` and `hashCode`.

Where people lose the point

  • Using a List for membership tests, leading to O(n) performance.
  • Assuming Sets maintain insertion order (they do not).
  • Forgetting to override `hashCode` when using custom objects in Sets or as Map keys.
Link to this question

7.How do generics work in Dart? What does it mean that generics are reified?

Core

What a strong answer covers

  • Explain that generics allow type parameters on classes, methods, and functions.
  • Mention that generics provide compile-time type safety.
  • Define reified generics: type information is preserved at runtime, unlike type erasure in Java.
  • Give an example: `List<int>` can be checked at runtime with `is List<int>`.
  • Discuss covariance and how `List<Dog>` is a subtype of `List<Animal>`.

Where people lose the point

  • Thinking that Dart has type erasure like Java.
  • Assuming that `List<Object>` can accept a `List<int>` without issues (it can, but not vice versa).
  • Misunderstanding covariance and causing runtime type errors.
Link to this question

8.What is a factory constructor in Dart? How does it differ from a generative constructor? Provide an example.

Core

What a strong answer covers

  • Define a factory constructor as a constructor that doesn't always create a new instance; it can return an existing object or a subtype.
  • Explain that factory constructors use the `factory` keyword and must return an instance of the class or a subtype.
  • Contrast with generative constructors that always create a new instance and use initializer lists.
  • Give an example: a `Cache` that returns a cached instance if available.
  • Mention that factory constructors cannot access `this`.

Where people lose the point

  • Trying to use an initializer list in a factory constructor.
  • Forgetting to return an instance from a factory constructor.
  • Using factory constructors when a generative constructor would suffice.
Link to this question

9.What are extension methods in Dart? How do they work and what are their limitations?

Core

What a strong answer covers

  • Define extension methods as a way to add functionality to existing classes without modifying them.
  • Explain syntax: `extension MyExtension on String { ... }`.
  • Mention that extensions are resolved statically based on the static type of the receiver.
  • Discuss limitations: cannot override existing methods, cannot access private members, and are not virtual.
  • Give an example: adding a `toInt()` method to `String`.

Where people lose the point

  • Thinking extensions can override existing methods.
  • Assuming extensions are dynamically dispatched.
  • Trying to access private fields of the extended class.
Link to this question

10.How does operator overloading work in Dart? What operators can be overridden? What are the pitfalls?

Hard

What a strong answer covers

  • Explain that Dart allows overriding operators like `+`, `-`, `*`, `/`, `==`, `[]`, etc.
  • Mention that operators are defined as methods with the `operator` keyword.
  • Discuss the importance of overriding `==` and `hashCode` together for consistency.
  • Mention that you cannot create new operators, only override existing ones.
  • Give an example of a `Vector` class with `+` and `==`.

Where people lose the point

  • Overriding `==` without `hashCode`, breaking collections.
  • Changing the semantics of an operator in a surprising way.
  • Overriding operators that are not commonly used, leading to confusion.
Link to this question

11.What is pattern matching in Dart? How can it be used with switch expressions and destructuring?

Hard

What a strong answer covers

  • Define pattern matching as a way to match values against patterns and destructure data.
  • Explain that patterns can be used in variable declarations, switch expressions, and if-case statements.
  • Mention that switch expressions can now return values and use patterns.
  • Give an example of destructuring a record or a list.
  • Discuss how patterns can check types and bind variables.

Where people lose the point

  • Thinking pattern matching is only for switch statements.
  • Not understanding that patterns can be used in many contexts.
  • Using patterns incorrectly with null safety, leading to errors.
Link to this question

12.What are records in Dart? How do they differ from classes? When would you use a record?

Core

What a strong answer covers

  • Define records as lightweight, immutable data structures that group values.
  • Explain syntax: `(int, String)` or named fields `({int x, String y})`.
  • Mention that records have structural equality, meaning two records with same values are equal.
  • Contrast with classes that have identity equality unless overridden.
  • Give an example: returning multiple values from a function using a record.

Where people lose the point

  • Using records for complex behavior that requires methods.
  • Assuming records are mutable.
  • Confusing positional and named fields.
Link to this question

13.How does error handling work in Dart? What is the difference between `Exception` and `Error`?

Warm-up

What a strong answer covers

  • Explain that Dart uses exceptions for programmatic errors and errors for system-level issues.
  • Mention that `Exception` is meant to be caught and handled, while `Error` indicates a bug that should not be caught.
  • Describe try-catch-finally syntax.
  • Mention `on` clauses to catch specific exception types.
  • Discuss best practices: don't catch all exceptions blindly, rethrow when necessary.

Where people lose the point

  • Catching `Error` types, which can hide serious bugs.
  • Using empty catch blocks without logging.
  • Not using `finally` for cleanup.
Link to this question

14.What are isolates in Dart? How do they differ from threads? How do you communicate between isolates?

Hard

What a strong answer covers

  • Define isolates as independent workers that have their own memory and event loops.
  • Explain that isolates do not share memory, so no locks are needed.
  • Mention that communication is done via messages using `SendPort` and `ReceivePort`.
  • Discuss that isolates are useful for CPU-intensive tasks to avoid blocking the UI.
  • Mention `Isolate.spawn` and `compute` function in Flutter.

Where people lose the point

  • Thinking isolates are like threads and share memory.
  • Trying to access variables from another isolate directly.
  • Not handling isolate termination properly.
Link to this question

15.Explain Dart's type system. What is sound typing? How does it relate to `dynamic`, `Object`, and `var`?

Core

What a strong answer covers

  • Define sound typing as a system where static types are guaranteed at runtime.
  • Explain that `var` infers the type from the initializer, but is not dynamic.
  • Contrast `dynamic` which disables type checking and can change type at runtime.
  • Explain that `Object` is the root of all types but doesn't allow calling specific methods without casting.
  • Mention that `dynamic` should be avoided in favor of proper typing.

Where people lose the point

  • Using `dynamic` excessively, losing type safety.
  • Confusing `var` with `dynamic`.
  • Thinking `Object` is the same as `dynamic`.
Link to this question

16.What are collection-if and collection-for in Dart? How do they improve code readability?

Warm-up

What a strong answer covers

  • Define collection-if as a way to conditionally include elements in a collection literal.
  • Define collection-for as a way to generate elements in a loop within a collection literal.
  • Give examples: `[if (condition) item]` and `[for (var i in list) i * 2]`.
  • Mention that they can be used in list, set, and map literals.
  • Explain that they reduce the need for temporary variables and loops.

Where people lose the point

  • Using collection-if without parentheses around the condition.
  • Thinking collection-for can only be used with lists.
  • Overcomplicating code with nested collection-for when a simple loop is clearer.
Link to this question

17.What is cascade notation (`..`) in Dart? How does it work and when is it useful?

Warm-up

What a strong answer covers

  • Define cascade notation as a way to perform multiple operations on the same object.
  • Explain that `..` allows you to chain method calls and property assignments without repeating the object.
  • Give an example: `list..add(1)..add(2)`.
  • Mention that cascades can be used with any expression, not just method calls.
  • Discuss that it improves readability by grouping operations on the same object.

Where people lose the point

  • Confusing cascade with dot notation.
  • Using cascade on a null object without null-aware cascade (`?..`).
  • Overusing cascades, making code less readable.
Link to this question

18.What are typedefs in Dart? How do they help in writing cleaner code?

Warm-up

What a strong answer covers

  • Define typedef as an alias for a function type.
  • Explain syntax: `typedef IntOp = int Function(int, int);`.
  • Mention that typedefs can be used for function parameters, return types, and variables.
  • Give an example of using a typedef to define a callback signature.
  • Discuss that typedefs improve code readability and maintainability.

Where people lose the point

  • Thinking typedefs are only for function types (they can also be for other types in newer Dart).
  • Not using typedefs for complex function signatures, leading to repetition.
  • Confusing typedef with type aliases for classes.
Link to this question
No account needed

Answer one real Dart question now

A question a Dart panel actually asks, answered out loud, scored on what you said and how you said it. Under two minutes, and nothing to sign up for.

Explain how Dart's null safety works. What is the difference between `String` and `String?`? How does type promotion help?

We never store the audio. Your answer is deleted within 24 hours unless you save the result.

How Dart answers get judged

The weights a Dart interviewer is holding, whether or not they say so out loud. Round Zero scores your practice answers against exactly these, and quotes your own words back as the evidence for each.

Correctness

40%

Accuracy of technical details and code examples; absence of factual errors.

Conceptual Depth

30%

Demonstrates understanding of underlying principles, not just surface-level knowledge.

Communication

20%

Ability to explain concepts clearly and concisely, using appropriate examples.

Practical Application

10%

Relates concepts to real-world scenarios and best practices.

Related More Programming skills

All skills →

Now say them out loud

You have read what strong Dart answers contain. The next thing that moves the needle is producing one under time, out loud, and finding out where it falls apart.

  • These questions asked back, with follow-ups
  • Flashcards for the ones you keep missing
  • A scored mock that quotes your own answers

Browse every skill

Practising Dart: common questions

What Dart interview questions should I practice?
Start with the core areas Dart interviewers probe: Explain how Dart's null safety works. What is the difference between `String` and `String?`? How does type promotion help; What is the difference between a `Future` and a `Stream` in Dart? Provide examples of when you would use each.; How do `async` and `await` work in Dart? What happens when you `await` a Future. This page outlines strong answers and common mistakes, and the scored path drills each one with follow-ups.
Is the Dart practice free?
Yes. The Dart path runs free inside Round Zero: lessons, practice questions and flashcards. Drills are unlimited on every plan, free included. So is the full scorecard. Free also covers 3 complete scored interviews, no card.
How is this different from a Dart question list?
A static list gives you questions with no feedback. Round Zero runs a live scored practice that probes your actual answers, rotates difficulty, and tells you exactly what to fix, grounded in a Dart rubric.
How should I prepare for a Dart interview?
Learn the concepts, drill the questions until answers come fast, then prove it in a scored mock. Round Zero sequences all three so you know you are ready, not just that you read about Dart.
How is a Dart answer scored?
Dart answers are scored on correctness, conceptual depth, communication, practical application, with evidence quoted from what you actually said, so feedback is specific instead of generic praise.