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 20

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

Flutter's Gesture Arena: Who Wins the Touch Event?

The Gesture Arena is a contest where multiple gesture detectors compete for one touch event. This happens when a tappable button is inside a scrollable list. The biggest footgun is a gesture not firing because an unexpected detector won the competition.

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

Build Custom Inputs with Flutter's FormField Widget

FormField is a state wrapper, not a UI widget, that turns any widget into a validatable form input. Use it for custom inputs like sliders or star ratings that must integrate with a Form. The footgun is forgetting to supply the UI via its builder.

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 & Dart1 min read

RawKeyboardListener: Deprecated Hardware Key Events in Flutter

This is a deprecated Flutter widget for capturing raw hardware keyboard events, bypassing text input systems. It was for games or custom shortcuts, but the biggest mistake is using it now. Use KeyboardListener instead.

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

MaterialPageRoute: The Page in Your Navigator Stack

Think of Navigator as a stack of screens. MaterialPageRoute wraps your new screen widget, defining its platform-specific transition (slide on iOS, zoom on Android). You use it with Navigator.push to show a new screen.

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

Imperative Navigation: Pushing and Popping Screens

Think of app screens as a stack of cards. You push a new screen onto the top to show it and pop it off to go back. It's ideal for linear flows like list-to-detail. The footgun: popping the last screen closes the app.

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

Flutter Named Routes: Navigate with Strings, Not Widgets

Think of named routes as URL paths for your app's screens. Instead of building a screen widget on the spot, you just tell Flutter "go to '/profile'". This is ideal for centralizing navigation in large apps and for enabling deep linking.

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

Passing Arguments to Flutter Named Routes

Flutter named routes pass data through an arguments field instead of global variables. Use this when navigating to a route that needs an ID or configuration object. Arguments are untyped by default, so unsafe casts crash at runtime.

Flutter & Dart2 min read

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

Use moveTo for the first point, lineTo for the rest, then Canvas.drawPath with a stroke Paint.

Flutter & Dart2 min read

GoRouter: URL-Based Navigation for Flutter Apps

GoRouter treats your app's screens like web pages with URLs. This declarative approach simplifies deep linking and passing data via paths like /users/123. The footgun is forgetting its declarative nature and trying to manage state imperatively.

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

Flutter's Router API: Declarative Navigation

The Router API treats navigation as state. You declare the page stack based on app state, giving you full control over URLs and the back button. This is vital for web/desktop apps but introduces significant boilerplate compared to simple push/pop navigation.

Flutter & Dart1 min read

Diagnosing and fixing CustomPainter jank

Avoid work in paint, gate repaints with shouldRepaint, isolate with RepaintBoundary, cache static layers.

Flutter & Dart2 min read

Flutter Hero Animations: Guiding the User's Eye

A Hero animation makes a widget appear to fly from one screen to another, connecting two UIs. It's perfect for transitioning a thumbnail to a detail page, guiding the user's focus. The main footgun is using non-unique tags, which causes animations to fail.