tezvyn:

Flutter & Dart

Flutter framework, Dart language, packages, Impeller

307 bites

More in Flutter & Dart — page 6

Flutter & Dart2 min read

What problem does IntrinsicWidth solve and what are its performance costs?

This tests Flutter constraints and intrinsic sizing. A great answer covers: capping width to the child's max intrinsic width, aligning Column children, and the speculative pass that costs O(N²) in tree depth. A red flag is omitting performance cost.

Flutter & Dart2 min read

Explain Flutter's 'constraints down, sizes up' rule and unbounded height error

WHAT IT TESTS: Flutter's constraint protocol. ANSWER OUTLINE: Parents constrain down, children size up. ListView in Column throws unbounded height as Column gives infinite maxHeight; fix with Expanded or shrinkWrap.

Flutter & Dart2 min read

Describe a strategy for ListView on phones and GridView on tablets

This tests Flutter adaptive layout skills. Use LayoutBuilder or MediaQuery to read screen width, pick a breakpoint near 600 dp, and return ListView or GridView conditionally.

Flutter & Dart2 min read

Fix RenderFlex overflow in Row with long truncating text

WHAT IT TESTS: Flutter Row constraints and bounding Text width for ellipsis without affecting sibling sizes. ANSWER OUTLINE: Wrap Text in Expanded; set overflow to TextOverflow.ellipsis and maxLines: 1; leave siblings unwrapped.

Flutter & Dart2 min read

How do Flexible and Expanded differ in a Row or Column?

Tests Flutter main-axis flex constraints. Key point: Flexible uses FlexFit.loose so the child may be smaller than its space share; Expanded uses FlexFit.tight so the child must fill its share.

Flutter & Dart2 min read

mainAxisAlignment vs crossAxisAlignment in Column, and textDirection in Row

Tests Flutter flex axis awareness. In a Column, mainAxisAlignment is vertical and crossAxisAlignment is horizontal. In a Row, textDirection governs the main axis, not crossAxisAlignment; verticalDirection governs the cross axis.

How do you split a Column 1/3 and 2/3 using Expanded?
Flutter & Dart2 min read

How do you split a Column 1/3 and 2/3 using Expanded?

Tests understanding of flex allocation in Flutter layouts. Strong answers wrap both containers in Expanded, assign flex values of 1 and 2, and note that Expanded forces children to fill the Column's main axis. Red flag: proposing fixed heights instead of flex.

In a Row, how do you space children evenly across the width?
Flutter & Dart2 min read

In a Row, how do you space children evenly across the width?

TESTS: Row main-axis layout and MainAxisAlignment. ANSWER: Set mainAxisAlignment to spaceEvenly; contrast with spaceBetween and spaceAround. RED FLAG: Using manual SizedBox spacers instead of the built-in alignment enum.

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

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

Explain the lifecycle of a State object

WHAT IT TESTS: Your grasp of StatefulWidget state transitions and framework hook timing. ANSWER OUTLINE: List initState through dispose, emphasizing didUpdateWidget reacts to parent config changes.

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

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

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.

Flutter & Dart2 min read

Relationship between Widget, Element, and RenderObject trees and their benefits

WHAT IT TESTS: Your understanding of Flutter's three-tree separation of concerns. ANSWER OUTLINE: Widget configures, Element owns state, RenderObject paints; Element.update reuses the RenderObject, so rebuilds stay cheap.

Flutter & Dart2 min read

What is the build method's purpose and key constraints?

WHAT IT TESTS: Your grasp of build as a pure, declarative function. ANSWER: It returns a Widget tree, can run every frame, must avoid side effects, and uses BuildContext for inherited data. RED FLAG: Async work, state mutation, or assuming build runs once.

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

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

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.

Flutter & Dart2 min read

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.