tezvyn:

Flutter & Dart

Flutter framework, Dart language, packages, Impeller

307 bites

More in Flutter & Dart — page 7

Describe the Dart event loop and queue execution order
Flutter & Dart2 min read

Describe the Dart event loop and queue execution order

Tests your grasp of Dart's single-threaded event loop priority. Great answers state: microtasks drain fully before the next event processes, cycling forever. Red flag: saying Future and scheduleMicrotask interleave in call order.

Flutter & Dart2 min read

Difference between Future<void> and void from an async function

WHAT IT TESTS: Knowledge that async always produces a Future. ANSWER OUTLINE: Future<void> lets callers await and catch errors; void hides the Future, preventing await and leaving exceptions uncaught. RED FLAG: Believing void async returns are awaitable.

Flutter & Dart2 min read

Define a Dart Future, return Future<String>, and handle errors with both patterns.

Tests Dart async primitives and error handling. A strong answer defines Future as a pending async result, writes a delayed Future<String>, consumes it with then/catchError, and mirrors with async/await try/catch.

Flutter & Dart2 min read

How does Dart resolve mixin method conflicts and application order?

Tests understanding of Dart's mixin linearization. Answer: Dart applies mixins left-to-right, building a superclass chain where the last mixin wins conflicts. Red flag: claiming first mixin wins or confusing with multiple inheritance.

Flutter & Dart2 min read

How do you model Product and safely parse JSON into List<Product>?

Tests bridging dynamic JSON to Dart's type system. A strong answer uses an immutable Product with a factory constructor that validates fields and converts types, mapping over the list. Red flag: leaving everything dynamic or assuming perfect API data.

Flutter & Dart2 min read

What is a Dart factory constructor and common use cases?

WHAT IT TESTS: When Dart factories beat generative constructors. ANSWER OUTLINE: Explain a factory need not create new instances and can return cached objects or subtypes; contrast with generative ones; give JSON or singleton examples.

Flutter & Dart2 min read

What are the key differences between Dart extends, implements, and with?

This tests your grasp of Dart's inheritance, interface, and mixin models. extends gives single inheritance; implements forces full reimplementation; with injects shared behavior.

Flutter & Dart2 min read

Deduplicate a List of emails in Dart

Tests knowledge of Dart's Set semantics and LinkedHashSet insertion order. The idiomatic solution is emails.toSet().toList(), which deduplicates in O(n) time while preserving order. Avoid manual loops with contains, which are O(n^2) and unidiomatic.

Flutter & Dart2 min read

Difference between final and const Dart class properties?

This tests your grasp of Dart's compile-time versus runtime constant model. A strong answer contrasts final variables set once with static const compile-time values, notes const is implicitly final, gives examples. Red flag: const as non-static instance field.

Flutter & Dart2 min read

Convert List<User> to Map<String, User> keyed by user id

Tests Dart collection-to-map idioms. A strong answer picks the for-element literal {for (var u in users) u.id: u}, mentions Map.fromIterable as a verbose alternative, and flags duplicate-key overwrites. Red flag: manually looping to populate an empty map.

Explain Dart's event loop, microtask queue, event queue, and await behavior
Flutter & Dart2 min read

Explain Dart's event loop, microtask queue, event queue, and await behavior

Tests Dart single-threaded event loop model. Strong answer: microtasks drain before event queue tasks; await suspends the function and schedules its resumption via the event loop when the Future completes. Red flag: claiming await blocks the thread.

Flutter & Dart2 min read

Explain Dart switch exhaustiveness for enums versus sealed classes

This tests Dart 3 exhaustiveness. A strong answer notes that enums and sealed classes both require exhaustive switches, but sealed classes allow distinct payloads because subclasses stay in the same library. A red flag is calling them just enums with methods.

Flutter & Dart2 min read

What are Dart extension methods? Implement toIntOrDefault on String.

Tests Dart extension syntax and static resolution. A strong answer defines an extension on String, uses int.tryParse with a fallback, and notes extensions do not mutate the original type. Red flag: using try-catch over tryParse or claiming dynamic dispatch.

Flutter & Dart2 min read

What is a Dart closure? Write a function that returns a function.

Tests lexical scoping: define a closure as a function plus its captured environment, show a makeAdder where the inner function uses a parent variable after the parent returns.

Flutter & Dart2 min read

How do you use collection-if and collection-for to declaratively build a list?

Tests Dart's declarative collection control-flow features. Answer: show collection-for to filter inside a literal, collection-if for conditional items, and combine both in one expression. Red flag: imperative loops and add() instead of literal syntax.

Flutter & Dart2 min read

What problem does late solve in Dart?

Tests definite assignment and lazy init in null-safe Dart. Strong answers cover: deferred non-nullable field init, lazy final evaluation, and LateInitializationError on early access. Red flag: treating late as nullable or saying it bypasses null safety.

Describe Dart's null-aware ?. and null assertion ! operators
Flutter & Dart2 min read

Describe Dart's null-aware ?. and null assertion ! operators

Tests Dart null safety mechanics: ?. short-circuits member access on null, while ! casts away nullability. A strong answer notes ?. avoids NPEs and ! is a risky opt-out. Red flag: claiming ! is safe or that ?. provides a default value.

Flutter & Dart2 min read

Explain Dart positional vs named parameters and write one signature

Tests Dart parameter syntax. A strong answer covers required positional args, optional positional args in square brackets, and named args in curly braces with defaults. Red flag: claiming named parameters are always optional or confusing bracket types.

Flutter & Dart2 min read

What is the difference between final and const in Dart?

Tests compile-time versus runtime immutability in Dart. A strong answer: final allows single assignment at runtime, but const requires a compile-time constant and deep immutability.

Flutter & Dart2 min read

Flutter Performance Overlay

Flutter's Performance Overlay is a real-time EKG for frame budgets. Two graphs reveal whether Dart UI work or GPU rasterization is causing jank during animations. The footgun is rewriting widget logic when the raster thread is actually the bottleneck.