Skip to content
tezvyn:

Top 30 Flutter & Dart Concepts Quiz

30 multiple-choice questions on the Flutter & Dart fundamentals, drawn from 30 bites in the Flutter & Dart library. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

Flutter framework, Dart language, packages, Impeller

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    Which keyword is best for a variable initialized at runtime from an API call, never to change?

    Show the answer

    Answer: a · final

    The 'final' keyword is used for variables whose values are determined at runtime and assigned once, making them immutable thereafter. 'const' is incorrect because it requires the value to be known at compile-time, which is not the case for an API response.

    Read the full bite: Dart Variables: var, final, and const

  2. Question 2 of 30

    What is a direct consequence of Dart's principle that "everything is an object"?

    Show the answer

    Answer: c · Even basic data types like integers and strings have callable methods.

    The core idea is that even simple types like int and String are objects, meaning they come with built-in methods and properties, unlike primitive types in other languages. Dart does not have primitive types that need conversion; all values are objects from the start, and 'null' itself is an object of type 'Null'.

    Read the full bite: Dart's Core Data Types: Everything is an Object

  3. Question 3 of 30

    What is the primary reason for using control flow statements in a program?

    Show the answer

    Answer: a · To allow the program to make decisions and repeat actions based on conditions.

    The card explains that control flow allows programs to "react to different inputs, repeat tasks, and handle problems," which directly translates to making decisions and repeating actions. Defining reusable code blocks (functions) is a separate concept, even though functions often contain control flow.

    Read the full bite: Dart's Control Flow: Telling Your Code What to Do Next

  4. Question 4 of 30

    What is the primary characteristic that makes Dart's arrow function syntax (=>) suitable for a function?

    Show the answer

    Answer: a · It implicitly returns the result of a single, concise expression.

    Arrow syntax is designed for functions that compute and return the result of a single expression, implicitly handling the return. Options A and B describe scenarios where a block body function is required, while option D incorrectly states that arrow syntax requires an explicit return keyword.

    Read the full bite: Dart Function Syntax: Block Body vs. Arrow Notation

  5. Question 5 of 30

    You need to store a collection of unique product SKUs that are currently in stock and frequently check if a particular SKU is available. Which Dart collection is the most efficient choice for this task?

    Show the answer

    Answer: a · Set, because it guarantees uniqueness and optimizes for fast existence checks.

    Set is specifically designed for storing unique items and provides highly efficient checks for an item's existence, making it ideal for this scenario. While a Map can also provide fast lookups, a Set is the most direct and efficient choice when only uniqueness and existence checking are required, without needing to associate a value.

    Read the full bite: Dart Collections: Choosing List, Set, or Map

  6. Question 6 of 30

    How does Dart's sound null safety fundamentally alter variable nullability?

    Show the answer

    Answer: b · Variables are non-nullable by default, requiring explicit opt-in for nullability.

    Dart's sound null safety makes variables non-nullable by default, meaning they are guaranteed to hold a value. To allow a variable to be null, developers must explicitly opt-in by adding a '?' to its type. Option D describes the opposite behavior, which is common in many other languages but not Dart with null safety.

    Read the full bite: Dart's Sound Null Safety: No More Null Errors

  7. Question 7 of 30

    Which statement accurately describes the primary function of Dart's null-aware access operator (?. )?

    Show the answer

    Answer: a · It safely attempts to access a member, returning null if the object itself is null.

    The null-aware access operator (?. ) safely checks if an object is null before attempting to access its members. If the object is null, the expression short-circuits and returns null, preventing a runtime error. Option D describes the if-null operator (??), and Option C describes the unsafe not-null assertion operator (!).

    Read the full bite: Dart's Null-Aware Operators: Safely Handle Nulls

  8. Question 8 of 30

    When using Dart's cascade notation (..), what is a crucial difference compared to standard method chaining (.)?

    Show the answer

    Answer: c · The entire cascade expression evaluates to the original object, not the result of the last operation.

    The card explicitly states that the cascade expression gives back the original object, not the result of the final task, which is the crucial difference from standard method chaining. Option B is incorrect because cascade notation modifies the original object in place and returns it, rather than creating a new one.

    Read the full bite: Dart's Cascade Notation: Chain Calls on One Object

  9. Question 9 of 30

    What is the most direct consequence of calling an `async` function in Dart without using the `await` keyword?

    Show the answer

    Answer: a · The variable assigned the result will hold a `Future` object instead of the completed value.

    The card explicitly states that forgetting `await` results in receiving a `Future` object instead of the actual data, which can lead to downstream type errors. The `async` function itself still executes non-blockingly, and it doesn't immediately throw an exception or prevent execution.

    Read the full bite: Dart's async/await: Non-Blocking Code That Reads Synchronously

  10. Question 10 of 30

    What primary problem do Dart generics address in software development?

    Show the answer

    Answer: b · Allowing code to operate on different data types without sacrificing compile-time type safety.

    Generics solve the problem of writing code that works with various data types while maintaining type safety at compile time, preventing errors that would arise from using less specific types like Object or dynamic. Option A is incorrect because generics enforce type safety at compile-time, which is distinct from dynamic typing that defers type checking to runtime.

    Read the full bite: Dart Generics: Type-Safe Containers and Reusable Code

  11. Question 11 of 30

    When is a Dart Stream the most appropriate choice for handling asynchronous data?

    Show the answer

    Answer: d · Processing a series of real-time sensor readings from an IoT device.

    Option D describes a continuous flow of data (real-time sensor readings), which is the primary use case for Dart Streams, as they handle sequences of asynchronous events over time. Options A, C, and D all represent scenarios where a single asynchronous value is expected, making a Future a more appropriate and simpler choice.

    Read the full bite: Dart Streams: Asynchronous Data Sequences

  12. Question 12 of 30

    Which statement accurately describes a limitation of static methods in Dart?

    Show the answer

    Answer: b · They cannot use the 'this' keyword or access instance-specific data.

    Static methods belong to the class, not an individual instance. Therefore, they cannot refer to instance-specific data or the 'this' keyword, which points to the current instance. Option D is incorrect because static methods are called directly on the class, without needing an instance.

    Read the full bite: Static Members: Belong to the Class, Not the Instance

  13. Question 13 of 30

    What is the primary benefit of Dart's `map()` and `where()` methods being lazy?

    Show the answer

    Answer: b · They reduce memory consumption by avoiding the creation of temporary intermediate lists.

    Lazy `map()` and `where()` methods defer computation until elements are actually requested, which prevents the creation of new, temporary lists for each step in a chain of operations. This significantly reduces memory overhead, especially for large datasets. Option C is incorrect because lazy iterables re-evaluate their operations each time they are iterated, unless explicitly materialized with `.toList()`.

    Read the full bite: Dart's Lazy Iterable Methods: map() and where()

  14. Question 14 of 30

    Which Dart constructor type is best suited for implementing a singleton pattern that returns a cached instance?

    Show the answer

    Answer: a · A factory constructor

    A factory constructor is designed to return an existing instance (e.g., from a cache) or a new one based on logic, making it ideal for singleton patterns. Named constructors always create new instances, and constant constructors focus on compile-time immutability and canonical instances, not runtime caching of a single instance.

    Read the full bite: Dart's Specialized Constructors: Named, Factory, and Constant

  15. Question 15 of 30

    Which Dart feature is best suited for defining an API contract that multiple unrelated classes must adhere to, without forcing them to inherit any shared implementation?

    Show the answer

    Answer: d · A regular class used as an implicit interface, implemented with the 'implements' keyword.

    An implicit interface, created from any regular class and used with 'implements', forces a class to provide its own implementation for every public member, ensuring an API contract without inheriting code. While an abstract class can define a contract (Option C), the card advises against using it if no code is shared, preferring a regular class as an interface for pure contracts.

    Read the full bite: Dart: Abstract Classes & Implicit Interfaces

  16. Question 16 of 30

    If a custom class overrides operator== but not hashCode, what is the primary consequence when its instances are used in a Set or as Map keys?

    Show the answer

    Answer: b · Hash-based collections may fail to correctly identify equal objects, leading to unexpected behavior like duplicates or missing elements.

    The core contract states that if two objects are equal by operator==, they must have the same hashCode. If hashCode is not overridden, two logically equal objects might have different hash codes, causing hash-based collections to treat them as distinct. This is a runtime logical error, not a compile-time error.

    Read the full bite: Why hashCode and operator== Must Be Overridden Together

  17. Question 17 of 30

    What core problem do Dart's enhanced enums primarily solve?

    Show the answer

    Answer: c · They integrate specific data and methods directly into each enumerated value.

    Enhanced enums allow data and behavior to be bundled directly with each enum case, preventing scattered logic that previously required external maps or extension methods. They do not support dynamic creation of instances, mutability of fields, or inheritance, as they are sealed classes with a fixed set of constant instances and final fields.

    Read the full bite: Dart's Enhanced Enums: More Than Just Constants

  18. Question 18 of 30

    What is the primary benefit of using the "on" keyword when defining a Dart mixin?

    Show the answer

    Answer: b · It enables the mixin's code to safely interact with members of the specified supertype.

    The primary benefit of 'on' is that it allows the mixin to safely access and utilize methods or properties from the constrained supertype, as the compiler guarantees their presence. While 'on' does act as a gatekeeper (Option A), this is the mechanism that enables the mixin to rely on and interact with the supertype's members, which is the ultimate benefit for the mixin's functionality.

    Read the full bite: Dart Mixins: Constraining Reusable Code with `on`

  19. Question 19 of 30

    Which scenario correctly describes a limitation of Dart extension methods?

    Show the answer

    Answer: a · They cannot be invoked on variables whose type is dynamic.

    The card explicitly states that extensions are resolved statically at compile time and cannot be called on variables of type dynamic. Extensions do not modify the original class, and existing instance methods always take precedence over extension methods with the same name.

    Read the full bite: Extension Methods: Add to Classes You Don't Own

  20. Question 20 of 30

    Which statement accurately describes the effect of using the covariant keyword on a method parameter in Dart?

    Show the answer

    Answer: c · It enables an overriding method to accept a parameter type that is a subtype of the overridden method's parameter type.

    The `covariant` keyword allows a subclass method to override a superclass method with a parameter type that is a more specific type (a subtype). While it relaxes compile-time checks, it introduces a runtime check to ensure type safety, meaning it does not disable type checking entirely or make it stricter at compile time.

    Read the full bite: The `covariant` Keyword: Loosening Type Rules

  21. Question 21 of 30

    Which statement best describes the primary function of the Dart event loop?

    Show the answer

    Answer: b · It manages the sequential execution of asynchronous operations and user input on a single thread, ensuring the UI remains responsive.

    The card explicitly states the event loop is a "single-threaded task manager" whose purpose is "to keep a user interface responsive" by processing events "one at a time." Option B accurately reflects this. Option C is incorrect because the event loop is single-threaded; heavy CPU tasks require spawning a new Isolate, not parallel execution by the event loop itself.

    Read the full bite: The Dart Event Loop: Your App's Task Manager

  22. Question 22 of 30

    In Dart, when chaining multiple .then() calls on a Future, what value is typically passed as an argument to a subsequent .then() callback?

    Show the answer

    Answer: a · The result returned by the immediately preceding .then() callback.

    The card states, "You can chain multiple .then() calls, passing the result of one to the next." This means each .then() receives the successful outcome of the previous step. Option B is incorrect because error handling is managed by .catchError(), not .then().

    Read the full bite: Dart Futures: Chaining Async Work with .then()

  23. Question 23 of 30

    Which statement accurately describes the default behavior of Future.wait when one of its constituent futures encounters an error?

    Show the answer

    Answer: a · It fails with the error from the first future that failed, discarding all other results.

    Future.wait operates on an 'all or nothing' principle by default; if any of the provided futures fail, the entire Future.wait operation fails with that error, and any results from other successful futures are discarded. It does not return partial results or indicate failure with nulls.

    Read the full bite: Future.wait: Run Concurrent Dart Operations

  24. Question 24 of 30

    Which scenario best describes when a Dart Stream is the most appropriate choice?

    Show the answer

    Answer: b · When you want to process a series of data events as they become available over time.

    A Stream is specifically designed to handle a sequence of asynchronous events delivered over time, acting as a data pipeline. Option A describes the primary use case for a Future, which handles a single asynchronous result.

    Read the full bite: Dart's Stream: Asynchronous Data Pipelines

  25. Question 25 of 30

    When is it essential to use StreamController.broadcast() instead of the default StreamController() constructor?

    Show the answer

    Answer: a · When the stream is expected to have multiple independent listeners at the same time.

    The card explicitly states that the default StreamController() creates a single-subscription stream and will throw an error if multiple listeners try to subscribe. StreamController.broadcast() is specifically for scenarios requiring multiple listeners. Other options describe features not directly related to this distinction.

    Read the full bite: StreamController: The Faucet for Your Data Stream

  26. Question 26 of 30

    Which scenario best illustrates the primary use case for Dart's Completer?

    Show the answer

    Answer: b · Wrapping a native platform channel call that signals completion via a callback.

    The card explicitly states that Completer's primary use is "wrapping non-Future-based asynchronous APIs" such as native platform callbacks. Other options describe scenarios typically handled by standard async/await, Isolate.run, or Future chaining methods, which are simpler and preferred when a Completer is not strictly necessary.

    Read the full bite: Completer: Manually Control a Future's Lifecycle

  27. Question 27 of 30

    What is the most significant consequence of placing a long-running or continuously scheduling task in Dart's microtask queue?

    Show the answer

    Answer: c · It will prevent the event queue from processing tasks, resulting in UI unresponsiveness and app freezes.

    The card explicitly states that a long-running or looping microtask "will permanently block the event queue, starving it of processing time," which "freezes the app, as UI rendering and user input are handled by the event queue." While other options might have some truth in different contexts, the critical issue highlighted for microtasks is the starvation of the event queue.

    Read the full bite: Dart's Microtask Queue vs. Event Queue

  28. Question 28 of 30

    Which outcome is expected when attempting to attach a second listener to a Dart stream that was originally created by an async* function, after its first listener has already completed?

    Show the answer

    Answer: c · A StateError will be thrown, indicating the stream cannot be listened to again.

    Single-subscription streams, such as those from async* functions, are designed for exclusive, single consumption. After the first listener completes, the stream is considered 'used' and will throw a StateError if a second listener attempts to subscribe, as it does not automatically convert to a broadcast stream.

    Read the full bite: Dart Streams: Single-Subscription vs. Broadcast

  29. Question 29 of 30

    When is a StreamTransformer the most appropriate tool for stream processing?

    Show the answer

    Answer: d · To create a reusable, stateful custom operator for processing stream events.

    A StreamTransformer is specifically designed for encapsulating complex, stateful, or reusable logic to create custom stream operators. Option B describes a simple transformation best handled by existing operators like 'map', which the card advises against using a transformer for.

    Read the full bite: StreamTransformer: Building Custom Stream Operators

  30. Question 30 of 30

    For which scenario would using a Dart Isolate be the most appropriate solution?

    Show the answer

    Answer: b · Decoding a large, complex JSON payload received from a server.

    The card specifies isolates are for CPU-intensive tasks like decoding large JSON to prevent UI jank. Fetching data is I/O-bound, simple calculations incur too much overhead, and isolates are not supported in Flutter web applications.

    Read the full bite: Dart Isolates: True Parallelism Without Shared Memory

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon