tezvyn:

Flutter & Dart

Flutter framework, Dart language, packages, Impeller

306 bites

More in Flutter & Dart — page 4

Flutter & Dart2 min read

What native iOS and Android config does the Flutter camera plugin need?

Tests native platform knowledge beyond Dart. iOS requires NSCameraUsageDescription and NSMicrophoneUsageDescription in Info.plist. Android needs minSdk 24 and choosing between CameraX or Camera2 implementations.

Flutter & Dart2 min read

Implement staggered animations using a single AnimationController and Interval

This tests multiplexing one ticker into sequential animations. Use one AnimationController, map each Tween to an Interval on distinct 0-to-1 sub-ranges, and rebuild with AnimatedBuilder. Red flag: multiple controllers or manual forward chaining.

Flutter & Dart2 min read

How would you draw a line graph using Canvas and Path?

WHAT IT TESTS: Fluency with Flutter's imperative drawing model and Path construction. ANSWER OUTLINE: Use moveTo for the first point, lineTo for the rest, then Canvas.drawPath with a stroke Paint.

Flutter & Dart2 min read

In a CustomPainter, what is the purpose of the shouldRepaint method?

This tests Flutter repaint optimization. Answer: shouldRepaint compares old and new delegates, returning true only when visual properties differ so the framework skips paint calls. A red flag is returning true unconditionally, forcing useless repaints.

Flutter & Dart2 min read

How does Tween work and how do you use ColorTween with Curves?

This tests value interpolation versus time remapping. A strong answer: Tween maps 0-1 to typed values; ColorTween lerps 2 colors; Curves.easeInOut warps input time before interpolation. Red flag: claiming the curve alters the color output instead of timing.

Flutter & Dart2 min read

Compare AnimatedBuilder and Transition widgets for explicit animations

Tests whether you know how explicit animations rebuild the widget tree and where to isolate animation effects. AnimatedBuilder rebuilds only its builder subtree, while Transition widgets rebuild their child when the animation ticks.

Flutter & Dart2 min read

How do AnimationController and TickerProvider work together to drive animations?

Tests your grasp of Flutter's imperative animation engine. AnimationController stores value and direction; TickerProvider (via vsync) schedules frame callbacks; paired they emit 60–120 ticks per second.

Flutter & Dart2 min read

Describe CustomPaint and CustomPainter and implement a circle

This tests Flutter's render delegation. Separate CustomPaint, the canvas widget, from CustomPainter, the drawing logic; cover canvas.drawCircle and shouldRepaint returning false. Red flags: calling setState in paint or ignoring shouldRepaint.

Flutter & Dart2 min read

Implicit vs explicit animations: AnimatedContainer or AnimationController?

Knowledge of Flutter's implicit versus explicit animation paradigms. Implicit widgets auto-animate property changes on rebuild; explicit controllers manage playback manually. Red flag: saying explicit is always superior or that implicit animations cannot stop.

Flutter & Dart2 min read

How do you safely add a non-nullable column in sqflite?

Tests onCreate for fresh installs vs onUpgrade for existing data. Outline: bump version; in onUpgrade use ALTER TABLE ADD COLUMN NOT NULL DEFAULT for existing rows; keep onCreate as latest schema. Red flag: only changing onCreate so old users crash.

Flutter & Dart2 min read

What is an sqflite transaction? Provide a practical example.

Tests atomicity in SQLite and isolate safety. A strong answer defines all-or-nothing execution, gives a fund-transfer example updating both, and warns sqflite transactions are not cross-isolate safe. Red flag: omitting rollback or multi-isolate writes.

Flutter & Dart2 min read

Key difference between shared_preferences and flutter_secure_storage for tokens

Tests at-rest encryption: shared_preferences stores plain text XML/plist, while secure storage uses iOS Keychain and Keystore with RSA OAEP plus AES-GCM. Answers cite backup risks and hardware keys. Red flag: calling prefs safe or relying on obfuscation.

Flutter & Dart2 min read

Why is Flutter local storage async and how do you use shared_preferences?

Tests why disk I/O must avoid blocking Dart's UI thread. A strong answer shows async/await with getInstance and setters, notes legacy getters are sync-after-cache, and warns writes may not persist instantly.

Flutter & Dart2 min read

When to use SQLite over key-value storage?

Tests structured-vs-flat storage judgment. Good answers cite relational data, complex queries, or multi-table schemas, then list adding the dependency, getting a path, opening with onCreate, and keeping a singleton.

Flutter & Dart2 min read

Why are stale search requests problematic and how do you cancel them?

This tests race conditions and resource waste in async UI. Strong answers note stale requests waste bandwidth and overwrite newer results; cancel the previous call with a CancelToken before issuing the next.

Implement an API caching layer with offline support and storage trade-offs
Flutter & Dart2 min read

Implement an API caching layer with offline support and storage trade-offs

WHAT IT TESTS: Designing a tiered cache for speed and resilience. ANSWER OUTLINE: Use in-memory for hot data and disk for offline, pick Hive or SQLite by shape, and use TTL with a sync queue. RED FLAG: Ignoring invalidation or treating all data identically.

Flutter & Dart2 min read

Explain Dio interceptors and automatic token refresh

WHAT IT TESTS: Stateful middleware and async orchestration. ANSWER OUTLINE: Define interceptors as hooks; queue concurrent 401s during refresh; retry with Bearer header via token manager. RED FLAG: Synchronous refresh or refresh storms.

Flutter & Dart2 min read

How would you manage network request state in a Flutter widget?

This tests whether you separate ephemeral widget state from business logic. A good answer defines a state class, uses setState in initState, then shows how a library moves logic out for testing and reuse. Red flag: fetch inside build or using boolean flags.

Flutter & Dart2 min read

Compare manual JSON serialization versus json_serializable

It tests build automation versus manual control in Dart serialization. Manual methods avoid build steps but risk drift; code generation cuts boilerplate but adds compile latency. Claiming code gen slows runtime or that manual is always simpler.

Flutter & Dart2 min read

Describe a robust error handling strategy for network requests

Tests whether you classify failures by layer rather than catching everything generically. Inspect DioExceptionType for connectivity, check HTTP status before parsing, and isolate JSON decode errors. Never show the same message for timeouts and 500s.