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 21
Building a custom implicitly animated widget
Extend ImplicitlyAnimatedWidget, use AnimatedWidgetBaseState, define tweens in forEachTween, read values in build.
PageRouteBuilder: Custom Routes Without the Boilerplate
PageRouteBuilder creates a custom page route on the fly, skipping the boilerplate of a full subclass. Just provide a pageBuilder for the screen's content and a transitionsBuilder for a unique animation.
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.
PopScope: Guarding Your Flutter Routes
PopScope acts as a gatekeeper for back navigation in Flutter, letting you intercept and block attempts to leave a screen. Use it to show a confirmation dialog for unsaved changes. Its behavior differs on iOS; the swipe-back gesture won't trigger its callback.
Explain the purpose of MethodChannel and how it enables Dart-to-native calls
MethodChannel lets Dart encode a method call; the platform host decodes it on the main thread, runs native code, and returns an async result.
MethodChannel data flow and type marshalling
Dart invokeMethod sends a StandardMessageCodec-serialized payload to native, which returns a primitive or map; complex objects must be reduced to supported types.
When to choose EventChannel over MethodChannel and native setup
It tests streaming versus one-shot platform communication. Pick EventChannel for ongoing native events like sensor data; register a StreamHandler on Android or iOS that feeds an event sink, then consume in Dart via receiveBroadcastStream.
Provider: Pass Data Down Your Widget Tree
Think of Provider as a delivery service for your app's data, passing it down the widget tree without sending it through every widget's constructor. It's a lightweight way to manage state. The footgun: never use .value to create a new object.
What is a Platform View and why is it crucial?
Tests embedding native UI when Flutter widgets fall short. Strong answers define Platform Views as native embeddings, cite maps or WebView, and contrast Hybrid Composition's native hierarchy with Virtual Display's texture rasterization.
ValueNotifier: Notifies on Replacement, Not Mutation
ValueNotifier is a simple state holder that tells widgets to rebuild when its single value is replaced. It's great for immutable data like a boolean toggle or counter.
Safely gating native OS version APIs in a custom Flutter plugin
Tests platform channel contracts and defensive native coding. Gate native calls with OS version checks, return result.error with an UNSUPPORTED code, handle PlatformException in Dart, and avoid Dart-only checks.
Present full-screen native SDK UI from Flutter and return a result
This tests platform channel architecture for full-screen native UI delegation. Use MethodChannel to launch the native controller, retain the async result callback, serialize the dismissal payload back to Dart, and avoid PlatformView for modal flows.

Cubit: Simple State Management in Flutter
A Cubit is a simple state manager that exposes functions to directly trigger state changes. It's ideal for managing local UI state, like a counter or form data, without the complexity of events. The footgun is expecting state to update synchronously.
What is Pigeon and how does it improve platform channels?
This tests type-safe platform channels versus manual MethodChannel boilerplate. Answer: Pigeon is a dev-time code generator that creates typed host stubs from a Dart contract, removing string keys and encoding. Red flag: calling it a runtime library.

Riverpod: Compile-Safe, Reactive State Management
Riverpod treats app state like a reactive formula. Define a piece of data once, and Riverpod automatically updates any UI that depends on it. It's ideal for network requests and shared state. Footgun: Watching a provider rebuilds the UI on every change.
Unit, widget, and integration test differences in Flutter
Tests your grasp of Flutter's test pyramid and isolation levels. Unit tests check pure Dart logic; widget tests verify UI in a headless environment; integration tests exercise the full app on a device. Red flag: saying widget tests require an emulator.
GetX State Management: Simplicity Over Boilerplate
GetX simplifies Flutter state management by removing boilerplate and avoiding code generators. It offers both simple manual updates and a reactive style. Use it for rapid development where minimal setup is key.
How do you verify a Text widget with 'Hello' is present?
Find.text('Hello') locates the widget; expect(finder, findsOneWidget) asserts exactly one exists.
Redux: Predictable State via a Single Source of Truth
Redux treats app state like a transaction log. All changes are explicit actions processed by pure functions, creating a new, predictable state. It's ideal for complex apps with shared state. The main footgun: putting side effects like API calls in reducers.
How do you widget-test states without real network calls?
This tests UI isolation from I/O. Mock the repository with Mockito, stub methods to yield loading, success, and error, and inject it via constructor or provider. Avoid real HTTP calls or unmocked clients in widget tests.