All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
8668 bites
Page 169
What are Keys in Flutter and why are they critical?
Tests widget identity during reconciliation. Keys let Flutter distinguish moved widgets from changed data; without ValueKeys, ReorderableListView leaves state at old positions, e.g., a checkbox swap. Red flag: calling them performance tools.
Explain the lifecycle of a State object
List initState through dispose, emphasizing didUpdateWidget reacts to parent config changes.
Explain lifting state up with a concrete scenario and benefits
Tests moving state to a common ancestor when siblings share data. Outline: pick two siblings, hoist state to the parent, pass values and callbacks down. Red flag: mutating a sibling via GlobalKey or choosing Provider before proving the parent cannot own it.
How can you prevent unnecessary child rebuilds in Flutter?
Tests your grasp of Flutter build-boundary isolation. Strong answers hit const constructors, extracting the child into its own widget, and granular state selectors. Red flag: saying Keys alone stop rebuilds or recommending RepaintBoundary to skip builds.
What is BuildContext? Give two tree-interaction examples.
Tests if you know BuildContext is an Element handle to a widget's tree location. Strong answers cite Theme.of and Scaffold.of as ancestor lookups, explain the own-context trap, and warn against caching across async gaps. Red flag: calling it the widget itself.
Relationship between Widget, Element, and RenderObject trees and their benefits
Widget configures, Element owns state, RenderObject paints; Element.update reuses the RenderObject, so rebuilds stay cheap.
What is the build method's purpose and key constraints?
It returns a Widget tree, can run every frame, must avoid side effects, and uses BuildContext for inherited data.
Explain StatelessWidget vs StatefulWidget and when to choose each
This tests immutable UI versus persistent state. StatelessWidget rebuilds when config changes; StatefulWidget owns State surviving rebuilds. Use StatelessWidget for static UI and StatefulWidget for interactive elements.
Explain StreamController, write a broadcast stream example, and why close it?
This tests Dart stream lifecycle and memory safety. A strong answer uses StreamController.broadcast(), adds data and errors, closes it, and explains unclosed controllers leak memory.
Fetch user profiles concurrently and handle individual failures
Tests Future.wait concurrency and per-future error isolation. Answer: map IDs to fetchProfile, pass to Future.wait. For partial failures, attach catchError per future to return null, then filter. Red flag: try-catch around Future.wait or sequential awaits.
Explain single-subscription vs broadcast Streams in Dart
Tests dart:async stream lifecycle. Outline: single-subscription allows one listener and emits on listen; broadcast supports many but drops events for late arrivals. Red flag: saying single-subscription allows multiple listeners or buffers events.

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.
Difference between Future<void> and void from an async function
Future<void> lets callers await and catch errors; void hides the Future, preventing await and leaving exceptions uncaught.
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.
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.
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.
What is a Dart factory constructor and common use cases?
Explain a factory need not create new instances and can return cached objects or subtypes; contrast with generative ones; give JSON or singleton examples.
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.
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.
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.