Skip to content
tezvyn:

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

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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').

Flutter & Dart2 min read

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
Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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
Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

Explain the lifecycle of a State object

List initState through dispose, emphasizing didUpdateWidget reacts to parent config changes.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.

Flutter & Dart2 min read

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.