All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
8664 bites
Page 15
Why hashCode and operator== Must Be Overridden Together
Overriding == without hashCode breaks collections like Set and Map. If two objects are equal, they MUST have the same hash code. This is vital for custom classes used as map keys or set 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.
Dart's Enhanced Enums: More Than Just Constants
An enhanced enum is a class with a fixed set of instances. It lets you add fields, methods, and constructors to your enums, turning them from simple labels into powerful objects with attached data and behavior.
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.
Dart Mixins: Constraining Reusable Code with `on`
A Dart mixin is like a plugin of methods for a class. The on keyword acts as a gatekeeper, ensuring the class using the mixin already has specific base features. This is used for sharing UI logic only among Widget subclasses.
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.
Extension Methods: Add to Classes You Don't Own
Extension methods let you add functionality to existing classes you don't control. Use them to create fluent APIs, like calling '42'.parseInt() instead of int.parse('42').
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.

The `covariant` Keyword: Loosening Type Rules
The covariant keyword tells Dart's analyzer to relax its strict rules for method overriding, letting a subclass method accept a more specific parameter type. It's often used in Flutter widgets.
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.

The Dart Event Loop: Your App's Task Manager
The event loop is Dart's single-threaded task manager. It processes one event at a time from a queue (like user taps or network responses), preventing the UI from freezing. Use async/await to avoid blocking it with long operations.
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.
Dart Futures: Chaining Async Work with .then()
A Dart Future is a promise for a value that isn't ready yet. Chain actions onto it with .then() for success and .catchError() for failure. This is key for network requests or file I/O. The footgun is forgetting .catchError(), causing silent failures.
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.
Explain the lifecycle of a State object
List initState through dispose, emphasizing didUpdateWidget reacts to parent config changes.
Future.wait: Run Concurrent Dart Operations
Run multiple async operations concurrently and collect their results in a single list. Use it to fire off independent tasks, like multiple network requests, and wait for them all to finish. The footgun: if one future fails, you lose all results by default.
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.
Dart's Stream: Asynchronous Data Pipelines
Think of a Dart Stream as a conveyor belt for asynchronous data, delivering events over time. It's ideal for handling sequences like user input or file I/O.
How does const on a widget constructor impact build and reconciliation?
Tests widget canonicalization and reconciliation. Strong answers: const creates identical widget instances; Element.updateChild skips subtree rebuild when oldWidget == newWidget, saving elements and GC.
StreamController: The Faucet for Your Data Stream
A StreamController is the faucet handle for your data stream. Use it to create a custom stream from any data source and push events to it. The main footgun is that a default controller only allows one listener; use StreamController.broadcast for multiple.